The Windows 10 version of tensorflow_gpu-2.10.0 is installed from scratch, and the compatibility of CUDA and CUDNN is guaranteed according to the official website

[Install the latest environment for python deep learning on Windows 10]
The update description of this article: If the installation experience makes you physically and mentally exhausted, please trust me, as long as you operate patiently again, you will be successful! ! !

Novice solemn reminder :
When installing the deep learning environment, you must not install it through a locally downloaded python application. Remember, you must not, otherwise you will encounter a series of pip download failures or slow speeds. Even changing the mirror image is not satisfactory, remember, this is not because your face is not white enough, it is because this method itself is not advisable or advisable! Also, if your cpu is too old (such as Core I3), it may not support some functions of the tensroflow library. This article is a bit long, please read it carefully if you want to configure it successfully! ! !
The most reliable way :
first install the python (anaconda), anaconda has built a python environment for us (check the version through python -V ) and a three-party library (such as: numpy, pandas), after installation, pass the conda activate command in DOS Activate the anaconda environment, download tensorflow and other libraries through pip combined with mirroring in the anaconda environment, and you will see that the download progress bar is fast. And the python environment you downloaded and installed separately will not conflict if you don’t delete it, please rest assured! After all, python is a dynamic language.

Download Instructions:

  1. Anaconda3-2020.07-Windows-x86_64.exe (this version has a built-in python3.8.3 version after installation, it is okay to install other python versions before, no conflict) https://www.anaconda.com/products/individual
  2. Install tensorflow-gpu-2.10.0 and keras through the pip command in the Anaconda3 environment (it will be fast to install TensorFlow and Keras in the form of pip+mirror in anaconda), even if tensorflow has built-in keras, it is recommended to install a copy independently
  3. Graphics card driver download covers the original driver, make sure the driver is newer, NVIDIA driver official website: https://www.nvidia.cn/Download/index.aspx?lang=cn# (Don’t forget: choose Studio driver as the download type (SD) )
  4. cuda_11.2.0 (about 2.8GB)
  5. cudnn-8.1(460MB)
  6. cudart64_101.zip (136KB) https://www.dll-files.com/cudart64_101.dll.html
    The picture below is the compatibility description of the corresponding program version provided by tensorflow official website :
    insert image description here
    Tip : If the computer does not have graphics card support, it can also be installed in this way, as long as Just skip the installation of parts 4, 5, and 6. The above roughly tells you the packages you should prepare to download, and then install them in the order above

Anaconda installation and download tensorflow-gpu and keras

Anaconda download address: https://www.anaconda.com/products/individual , click to enter the page, drag to the bottom to have the corresponding selection version, I chose the one of windows 64-Bit, the details are as follows:
insert image description here
anaconda installation attention Matters: If you check all the boxes, you don’t need to configure the environment variables yourself, and it comes with python3.8.3 (although the python version written in tensorflow’s official installation introduction is 3.7, but a higher version is totally fine), you don’t have to worry about other steps, follow the prompts and be bold Go, the installation path can also be customized. Check the following picture:
insert image description here

After the installation is complete, enter the dos system with the cmd command,
and enter conda activate to activate the anaconda environment, as follows:
insert image description here
enter python -V to view the python version, as follows:
insert image description here
enter pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple/ . As follows: You can find the tensorflow library you just downloaded in a path
insert image description here
like D:\Anaconda\Anaconda\Lib\site-packages .

Enter pip install keras -i https://pypi.tuna.tsinghua.edu.cn/simple/ to download keras. It is recommended to install a separate copy here, even if tensorflow has built-in keras, as follows:
insert image description hereSince it has been installed before, it prompts that it already exists Yes, you should see the progress bar running quickly when you download. So far, the python scientific deep learning kit has been downloaded, and you can exit the anaconda environment through conda deactivate .

After that, you will see the library just installed under the site-packages subpath of your anaconda. The specific path is as follows:
insert image description here

Graphics card driver download and installation

Go to the official website of Nvidia driver: https://www.nvidia.cn/Download/index.aspx?lang=cn# (When installing, select the configuration item according to the content of your graphics card. Here, the download type of my 1660Ti graphics card is Studio driver (SD) ), install it directly after the download is complete, the screen may flicker during the installation process, which is normal. In addition, if you encounter other interface bugs, just restart it. Tips : This step ensures that your graphics card driver is the latest version. If you ignore this step, the computer may restart inexplicably when installing cuda, which will cause the cuda installation to fail!

cuda_11.2.0 download and installation

Download address https://developer.nvidia.com/cuda-toolkit-archive , select 11.2.0:
insert image description hereinsert image description here

After the download is complete, install it. For beginners, it is recommended to install everything by default. The default installation will install all the packages. Here I also choose the default installation. I am only responsible for clicking next all the way. If you do not choose the default installation, what will be installed later? Things may not be executed in certain code scenarios. In addition, if your computer does not have a VS environment, there will be a warning about the lack of visual studio in the middle of the process. You can ignore it and continue to next. It may also report an error about a certain component of NVIDIA. You only need to open it in the computer control panel. It can be uninstalled accordingly. The screen will flicker during installation, which is normal. After the default installation is complete, the configuration of some environment variables will be omitted. Just configure the environment variables as follows, and fill in any missing items:
insert image description here

cudnn-11.0 download and installation

Unfortunately, to download cuDNN, you must register a free NVIDIA developer account https://developer.nvidia.com/cudnn-download-survey . After visiting the link, click the Join now button to register, and verify it in the email received halfway Just a click (Note: The delay in receiving emails may be a bit high, so be patient!). When you have an account and log in, you need to fill in some reasons for downloading, just fill in as you like!
Attach 3 pictures, the specific download process is as follows:
Picture 1:
insert image description here
Picture 2:
insert image description here
Picture 3:
insert image description here
After the download is completed, it is a compressed package file, just decompress it directly, including the three folders of bin, include, lib and a .txt text file. The next thing to do is to copy these three folders (not including the .txt text file) to the subpath corresponding to the previously downloaded cuda, as follows:
insert image description here

cudart64_101 download

After configuring all environments and preparing to run the code, I encountered a warning that cudart64_101 could not be found. The download address is https://www.dll-files.com/cudart64_101.dll.html , and then copy the decompressed cudart64_101.dll file to Similar to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin , refer to this path according to your specific path.

Finish

At this point, everything is over, attach a piece of code:

from keras.datasets import imdb

def run():
    (train_data, train_labels), (test_data, test_labels) = imdb.load_data(num_words=10000)
    print(train_data)
    print(type(train_data))
    print(train_labels[0])
    print(max([max(sequence) for sequence in train_data]))


if __name__ == '__main__':
    run()

The execution effect diagram is as follows:
insert image description here

Attach a small piece of code to detect whether GPU is supported, as follows:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

The execution effect diagram is as follows:
insert image description here
So far, the big announcement has been completed!

Since many installation environment configurations on the Internet are old versions, I wanted to try the latest one, and it went smoothly! In the later period, this article will be checked and filled up from time to time.
Creation date: 2020-08-09
Modification date: 2022-11-01

Guess you like

Origin blog.csdn.net/weixin_47834823/article/details/107893851