Scrabyard
Scrabyard

Reputation: 195

Conda Environment with specific Tensorflow and Numpy Version

I need to setup a conda environment for tensorflow. I do so via environment.yml file. I have to specify my version of tensorflow (latest 2.5.0) because otherwise conda installs tf 1.14. But because tensorflow seems not to work properly with the latest numpy version I want to use numpy 1.19 or older. With the following environment.yml conda cannot solve the environment, it says Found conflicts! Looking for incompatible packages. but after that conda is not able to solve the problem.

name: gi-project
channels:
  - conda-forge
  - defaults
dependencies:
  - numpy=1.19
  - tensorflow=2.5.0
  - matplotlib
  - jupyterlab
  - pandas
  - joblib
  - scikit-learn
  - netcdf4

Why is this? I thought the reason for conda environments is to deal with different versions of packages?

Upvotes: 1

Views: 2589

Answers (2)

Robby Parker
Robby Parker

Reputation: 11

I was having similar problems with numpy and tensorflow not being compatible with each other.

I came across a gist that suggested this incompatibility had been fixed in tensorflow 2.7 and later

For me, downloading tensorflow 2.10.0 required using the condaforge channel:

conda install -c conda-forge tensorflow

Upvotes: 0

FlyingTeller
FlyingTeller

Reputation: 20462

conda looks at the packages that you want to install, check their dependencies and then determines which versions will work together. Package maintainers thereby impose limits. If we do

conda search --info tensorflow

we see that it has a dependency for tensorflow-base=2.5.0:

tensorflow 2.5.0 mkl_py38hbe2df88_0
-----------------------------------
file name   : tensorflow-2.5.0-mkl_py38hbe2df88_0.conda
name        : tensorflow
version     : 2.5.0
build       : mkl_py38hbe2df88_0
build number: 0
size        : 4 KB
license     : Apache 2.0
subdir      : win-64
url         : https://repo.anaconda.com/pkgs/main/win-64/tensorflow-2.5.0-mkl_py38hbe2df88_0.conda
md5         : dc6f851db06000dc1e22965fc7f8946a
timestamp   : 2021-07-02 17:21:52 UTC
dependencies:
  - _tflow_select 2.3.0 mkl
  - python 3.8.*
  - tensorboard >=2.5.0
  - tensorflow-base 2.5.0 mkl_py38h9201259_0
  - tensorflow-estimator >=2.5.0

Going further down the line, doing conda search --info tensorflow-base=2.5.0:

tensorflow-base 2.5.0 mkl_py38h9201259_0
----------------------------------------
file name   : tensorflow-base-2.5.0-mkl_py38h9201259_0.conda
name        : tensorflow-base
version     : 2.5.0
build       : mkl_py38h9201259_0
build number: 0
size        : 63.3 MB
license     : Apache 2.0
subdir      : win-64
url         : https://repo.anaconda.com/pkgs/main/win-64/tensorflow-base-2.5.0-mkl_py38h9201259_0.conda
md5         : fe8fa6dfa600d9158984e0676cf000db
timestamp   : 2021-06-25 13:11:22 UTC
dependencies:
  - abseil-cpp >=20210324.2,<20210324.3.0a0
  - absl-py >=0.10.0
  - astunparse >=1.6.3
  - flatbuffers
  - gast 0.4.0
  - giflib >=5.2.1,<5.3.0a0
  - google-pasta >=0.2
  - grpcio
  - h5py >=3.1.0
  - icu >=68.1,<69.0a0
  - jpeg >=9b,<10a
  - keras-preprocessing >=1.1.2
  - libcurl >=7.71.1,<8.0a0
  - libpng >=1.6.37,<1.7.0a0
  - libprotobuf >=3.14.0,<3.15.0a0
  - numpy >=1.20
  - openssl >=1.1.1k,<1.1.2a
  - opt_einsum 3.3.0.*
  - protobuf >=3.9.2
  - python >=3.8,<3.9.0a0
  - python-flatbuffers 1.12.*
  - scipy >=1.6.2
  - six >=1.15.0
  - snappy >=1.1.8,<2.0a0
  - sqlite >=3.36.0,<4.0a0
  - tensorboard >=2.5.0,<2.6
  - tensorflow-estimator >=2.5.0,<2.6
  - termcolor >=1.1.0
  - typing_extensions >=3.7.4
  - vc >=14.2,<15.0a0
  - vs2015_runtime >=14.27.29016,<15.0a0
  - wheel >=0.35,<0.36
  - wrapt >=1.11.2
  - zlib >=1.2.11,<1.3.0a0

As you can see, numpy>=1.20 is a requirement. Therefore conda can only go ahead and determine that your requirements are not possible to go together, as whoever has created the tensorflow-base=2.5.0 package has specified that it will not work with numpy<1.20

I suggest you try with numpy=1.20 if you want to avoid the latest version (1.21)

Upvotes: 3

Related Questions