TensorFlow environment installation CUDA_cuDNN_Py37_TF-GPU/Py37_TF-CPU/Py27

foreword

Before executing the following virtual environment creation, you need to install Anaconda (the latest version is sufficient). If the download speed of the package is slow during the creation process, you can consider changing the source (method online search).

All files used:
Link: https://pan.baidu.com/s/1J_YWJXJPpTh-DgKFAlzeCA
Extraction code: afrx

py37tfgpu

Python3.7.13+TensorFlow-gpu2.3.0+cuDNN7.6.5+CUDA10.1

Install CUDA10.1

  1. Open cuda_10.1.168_425.25_win10.exe

  2. Customize the installation, select only the CUDA unit, and cancel VS Integration under it

    image-20220411081546151

  3. Check system variables

    image-20220410154403002

    image-20220411090707367

  4. Ctrl + R, enter cmd to enter the command line, enter nvcc -V to view the cuda version number, if it appears, the installation is successful

    image-20220410154626298

Install cuDNN7.6.5

  1. Unzip cudnn-10.1-windows10-x64-v7.6.5.32.zip
  2. Copy all the files in it to the path C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

Install Py3.7.13+TF2.3.0

Execute in Anaconda Prompt pay attention to order

1. 创建环境(删除环境为conda remove -n [env_name] --all,然后在anaconda\envs文件夹下删除[env_name]文件夹)
conda create -n py37tfgpu python=3.7.13
2. 进入环境(退出环境用conda deactivate)
conda activate py37tfgpu
conda install cudatoolkit=10.1
conda install cudnn=7.6.5
3. 安装tensorflow-gpu
conda install tensorflow-gpu==2.3.0

test

Execute in Anaconda Prompt

1. 输入python进入代码编辑
2. 输入以下程序
import tensorflow as tf
print(tf.test.is_built_with_cuda())
print(tf.test.is_gpu_available())

If True True is output, the installation is successful.

py37tfcpu

Python3.7.13+TensorFlow2.3.0

1. 创建环境(删除环境为conda remove -n [env_name] --all,然后在anaconda\envs文件夹下删除[env_name]文件夹)
conda create -n py37tfcpu python=3.7.13
2. 进入环境(退出环境用conda deactivate)
conda activate py37tfcpu
3. 安装tensorflow
conda install tensorflow==2.3.0

test

Execute in Anaconda Prompt

1. 输入python进入代码编辑
2. 输入以下程序
import tensorflow as tf
print(tf.__version__)
a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)

Output 2.3.0 tf.Tensor(3.0, shape=(), dtype=float32), the installation is successful.

py27

1. 创建环境(删除环境为conda remove -n [env_name] --all,然后在anaconda\envs文件夹下删除[env_name]文件夹)
conda create -n py27 python=2.7
2. 进入环境(退出环境用conda deactivate)
conda activate py27
3. 测试
1)输入python进入代码编辑
2)输入以下程序
print 'Hello World!'
3)输出Hello World安装成功

Due to the suspension of maintenance of Python 2.7 after 2020, the installation of tensorflow 1 failed, and the files that may be used are still placed in the Baidu network disk.

image-20220411120119315

Guess you like

Origin blog.csdn.net/qq_42283621/article/details/124095937