Windows the simplest three line command to install tensorflow GPU Version (using Anaconda) does not need to install CUDA yourself

Time:2020-9-29

The installation methods of tensorflow GPU that can be found on the Chinese Internet are very troublesome. You need to look at your graphics card, see your graphics card driver, go to NVIDIA official website to download CUDA or something, which is not necessarily compatible with the tensorflow you installed last. Including me, I was also hurt by these spicy chicken articles and wasted an afternoon. Finally, it is found that the corresponding CUDA can be automatically matched and installed by using CONDA directly, and the version can be selected at will, which is very convenient.

1. Install anaconda

Enter the official website, pull to the bottom, according to your system is 64 or 32-bit download installation, win10 is generally 64 bit. Install by default.
Windows the simplest three line command to install tensorflow GPU Version (using Anaconda) does not need to install CUDA yourself

2. Install tensorflow

Open Anaconda prompt, and

1. Create tensorflow virtual environment

conda create -n tensorflow python=3.7

2. Activate the environment

conda activate tensorflow

3. Install tensorflow

The following command installs the latest version of tensorflow that matches your driver by default:
conda install tensorflow-gpu
If you want to install the specified version, such as 1.10.0, use the following command:
conda install tensorflow-gpu=1.10.0
If you want to install the CPU version, use the following command:
conda install tensorflow
If there is an error in the installation process, it is generally a network problem. As you know, surf with Ke Xue

4. Test after installation

Enter firstpythonEnter the python interactive environment and enter the following code:

import tensorflow as tf 
print(tf.__version__)
print(tf.test.is_gpu_available())

The expected result should be as shown in the figure below. The final output is true, indicating that the GPU is used, which indicates that the installation is successful.
Windows the simplest three line command to install tensorflow GPU Version (using Anaconda) does not need to install CUDA yourself