Windows安装tensorflow-gpu(1050Ti,cuda11.6,cuDNN7.6.5,python3.6,tensorflow-gpu2.3.0)

Reference: https://blog.csdn.net/qq_43215538/article/details/123852028

install cuda

First check the cuda version corresponding to the local GPU, as shown in the figure below, the local cuda version is 11.6, and the cuda version selected later should not exceed the version here.
2.
https://developer.nvidia.com/cuda-toolkit-archive Select the corresponding cudatoolkit version to download. If you choose the version here, you must pay attention, because the cuda version will determine the version of cudnn and tensorflow-gpu you download. If they are inconsistent, it will appear Unable to use due to issues such as version mismatch. I choose 10.1 here.
insert image description here
The version selected here affects the versions of tensorflow-gpu and cudnn, which need to be corresponding. The corresponding relationship can be seen here: https://tensorflow.google.cn/install/source_windows
insert image description here
After downloading the cuda installation package, double-click to install it. After the installation is complete, the environment variables should be added automatically.
insert image description here
insert image description here
insert image description here

Download cuDNN

Download URL: https://developer.nvidia.com/rdp/cudnn-archive . When you click download for the first time, you will be asked to register and log in first, and then download. It is no problem to fill in the content carefully during the registration process. Here Skip it, and then enter the download link.

According to the above version correspondence, download version 7.6.5 here.
insert image description here
After the download is complete, unzip the file, and move the corresponding files in the cudnn file to the corresponding installation directory of cuda. It is the following table, the files on the left are moved to the directory on the right.

Unpacked cudnn file Installed cuda directory
bin\cudnn64_7.dll C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
include\cudnn.h C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include
lib\x64\cudnn.lib C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64

Install tensorflow-gpu

Create python3.6 virtual environment

conda create -n tf python=3.6

Activate the environment

conda activate tf

Then you can use conda or pip to install the version corresponding to tensorflow-gpu. I choose 2.3.0 here, and here I use pip Douban source to install it, which is very fast.

pip install tensorflow-gpu==2.3.0 -i https://pypi.douban.com/simple

Wait for the installation to complete and test it:

import tensorflow as tf
tf.autograph.set_verbosity(0)
physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
config = tf.config.experimental.set_memory_growth(physical_devices[0], True)

insert image description here

Guess you like

Origin blog.csdn.net/Sky_QiaoBa_Sum/article/details/128212284