Anaconda has different packages for Tensorflow with and without GPU support.
In particular, to install Tensorflow with GPU, you should run:
conda install tensorflow-gpu
While for the non-GPU version, you should install:
conda install tensorflow
By checking the version of the installed package, conda installs Tensorflow version 2.1.
But as of today the latest version of Tensorflow is 2.3. Furthermore, as can be seen in the Tensorflow officla documentation , the latest version can be installed with
pip install tensorflow
This package is said in the documentation to be good both for CPU and GPU versions of Tensorflow. Moreover, the documentation states that the packages for CPU and GPU were different for "for releases 1.15 and older".
Why Anaconda provides 2.1 in two different packages, given that the package should be the same for any version > 1.15?
Which one should I install, the pip version or the conda version? An article in Anaconda blog specifies that the version provided with conda is faster, but the article is old (2018) and refers to an old version of Tensorflow (1.10)
By checking the version of the installed package, conda installs Tensorflow version 2.1. But as of today the latest version of Tensorflow is 2.3. Furthermore
That is only because you are (probably?) on windows. As you can see here tensorflow
is available as 2.3 from conda
default channels, but currently only on linux.
The reason is also stated on the website you have linked (emphasis mine):
Anaconda is proud of our efforts to deliver a simpler, faster experience using the excellent TensorFlow library. It takes significant time and effort to add support for the many platforms used in production, and to ensure that the accelerated code is still stable and mathematically correct. As a result, our TensorFlow packages may not be available concurrently with the official TensorFlow wheels . We are, however, committed to maintaining our TensorFlow packages, and work to have updates available as soon as we can.
In short: The Anaconda team is creating custom builds of tf against the intel mkl library to speed up calculations on the CPU. Earlier on the same website they also mention that they create builds for different cuda versions.
Why Anaconda provides 2.1 in two different packages, given that the package should be the same for any version > 1.15?
The tensorflow-gpu
package is only a meta-package, ie it is only used to install a different build of tensorflow
with different dependencies (also enabling you to install for different cuda versions). The official releases only allow for combinations of tensorflow version and cuda.
Which one should I install, the pip version or the conda version? An article in Anaconda blog specifies that the version provided with conda is faster, but the article is old (2018) and refers to an old version of Tensorflow (1.10)
Reading said article, the speed up is linked to building against the intel mkl library, which speeds up calculations on the CPU. Given that for your setup, you can only get tensorflow
2.1 installed when using conda
, you will need to ask yourself if you rely on the newest tensorflow
version and if you don't need the accelerated cpu code. There is usually nothing wrong with installing the newest tensorflow using pip
. Just make sure that you create a new environment for said tensorflow version and only install/update tensorflow or any of its dependencies using pip
in that environment. There is general advice to not mix conda
and pip
installations too much, since one could break the other (since they are using different ways to resolve dependencies), but you should be fine when using a seperate env
If you are using Anaconda then you can use conda to install tensorflow. For the cpu version enter
conda install tensorflow
for the gpu version enter
conda install tensorflow-gpu.
If you are using Windows it will install version 2.1.0, the cuda toolkit version 10.1.243 and cudnn version 7.6.5. Note conda can only install tensorflow up to version 2.1.0 on Windows operating system. If you want tensorflow 2.2.0 or 2.3.0 install it with pip using pip after you have installed 2.1. The cuda toolkit and cudnn work with version 2.2 and 2.3. One other thing. Use python3.7 not 3.8. Apparently when you install tensorflow with conda it will not work with 3.8. If you use pip to install tensorflow 2.1 or higher it includes both the cpu and gpu versions however you have to go through a manual processes to install the Cuda Toolkit and cudnn. This includes downloading the files from NVIDIA . You also have to change your PATH environmental variable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.