Win 10 64-bit server RTX3080Ti graphics card installation TensorFlow and Pytorch practice (2021.9.22)
1. Environment
1.1 Server + RTX3080Ti graphics card (hardware)
|
|
I believe everyone knows that in addition to a powerful CPU and running memory , if a high-performance server has a high demand for graphics rendering, the server should also be equipped with a better independent graphics card, because existing computers (notebooks, laptops, etc.) desktops, servers) are increasingly unable to meet the needs of study, work and scientific research, especially for college students and graduate students majoring in artificial intelligence , computers , pattern recognition , electronic information , etc.A good graphics card can not only enhance the image display capability, but also greatly speed up the training speed of the deep learning network model to optimize the parameter adjustment。
1.2 Win 10 operating system + NVIDIA graphics driver (software)
The server has installed the Win 10 professional operating system , the running memory is about 32GB , the CPU is 16 cores and 32 threads , the graphics card device has been identified in the server, and it can be viewed in the computer right->properties->device manager.
|
|
1.3 NVIDIA graphics card driver installed (Version 471.11)
The graphics card driver of version 471.11 is selected here (you can download it from NVIDIA’s official website or contact the service provider). After the installation is complete, right click on the desktop to enter the NVIDIA control panel, and you can view it in the system information of the control panel.The graphics card driver version corresponding to this graphics card is 471.11andThe supported CUDA version is 11.4. (You can also use Win+ Rto open the cmd window and enter nvidia-smi
commands to view)
|
|
1.4 Master Lu running points (excited)
Just like many gamers, after installing the graphics card driver for a newly purchased graphics card, they all hope to use Master Lu to conduct a performance benchmark test and identify the authenticity of the hardware, so let me test RTX 3080Ti
the power of it too!
|
|
|
|
2. Install CUDA and CUDNN for the graphics card (Version 11.4)
Go to NVIDIA official website CUDA to find the CUDA version supported by the RTX 3080Ti graphics card and the CUDNN version compatible with CUDA, and finally choose CUDA 11.4 and CUDNN 11.4 . It should be noted that you can right-click and copy the link address on the download page of CUDA and CUDNN , and then use Thunder Download can effectively increase the download speed.
|
|
end useThunderThe downloaded CUDA 11.4 and CUDNN 11.4 installation package files are shown in the figure below.
2.1 Install Visual C++ support (before installing CUDA)
The 64-bit Win10 operating system needs to download the Visual C++ support file VC_redist.x64.exe , and double-click to install it.
2.2 Install CUDA11.4
Double-click cuda_11.4.0_471.11_win10.exe
the installation package file to enter the NVIDIA installation program interface, choose to accept the software license agreement , and then you need to select the installation location and directly default it. In the custom installation program interface, since the graphics card driver has been installed, some components in the CUDA installation package have already been installed. It has been installed, here you can check it with the installed programs (applications and functions) in the control panel, because it has already been installed
|
|
After CUDA is successfully installed, open Computer -> Properties -> Advanced System Settings -> Environment Variables, check whether there are two environment variables under System Variables CUDA_PATH
, CUDA_PATH_V11_4
the corresponding value is the default installation directory of CUDA (if not, you need to create a new one manually these two environment variables).
Then WIn+ Ropen the cmd command line window, enter nvcc -V
and press Enter to view CUDA-related information ( such as version, compiler driver ) and the installation is successful.
2.3 Install CUDNN11.4 (copy the files under the bin, include, and lib folders to the corresponding CUDA directory)
First unzip cudnn-11.4-windows-x64-v8.2.2.26.zip
the cudnn-11.4-windows-x64-v8.2.2.26
folder, you need to copy the files in bin
the folder, include
the folder and the folder lib
under the folder tox64
The bin folder, include folder under the CUDA installation directory and the x64 folder under the lib folder。
|
|
|
|
|
|
3. Use Conda to install TensorFlow and Pytorch
3.1 Install Anaconda (Python)
Go to the Anaconda official website to download the Windows system installation package, and install it directly after downloading.
|
|
After the Anaconda installation is complete, you can see the Anaconda folder in the start menu, open Anaconda Prompt
the command line window, in orderImprove the speed of Anaconda downloading dependent packages, and configure domestic Tsinghua source mirroring, enter the following command:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
To understand the common commands of Anaconda, such as viewing the list of existing environments conda info --envs
, creating a Python environment conda create --name env_name python=3.6
, entering an environment conda activate env_name
, viewing all dependent packages in the current environment pip list
, and entering the Python command line python
, here I created two virtual environments tensorflow_gpu and pytorch_gpu, using To configure TensorFlow and PyTorch.
conda create --name tensorflow_gpu python=3.6
conda create --name pytorch_gpu python=3.6
|
|
3.2 Install TensorFlow (GPU version)
In the Anaconda Prompt command line window interface, enter conda activate tensorflow_gpu
the command to enter the environment, and then enter it pip install tensorflow-gpu==2.5.0
to install the relevant dependency packages. The following figure shows the detailed information during the installation process. After the installation is complete, you can enter pip list
to view the dependent packages installed in the tensorflow_gpu environment.
|
|
After the installation is complete, after entering python in the tensorflow_gpu environment, you can enter the following code to test whether the GPU version of TensorFlowTrue
is successfully installed. If it shows that it also includes information about the graphics card, the installation is successful.
import tensorflow as tf
print(tf.test.is_gpu_available())
3.3 Install PyTorch (GPU version)
First go to the PyTorch official website and select the configuration as shown in the figure below. You can see that this command is automatically generated. After pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio===0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
careful analysis, we found that we have already configured the CUDA environment. Now we should still need to install the torch dependency package, so we open https:// Download.pytorch.org/whl/torch_stable.html page, find the corresponding version of the torch dependency package file torch-1.9.0+cu111-cp36-cp36m-win_amd64.whl
(corresponding to CUDA 11 version, Python 3.6 and Windows 64-bit operating system) and download it, and then enter the Scripts folder under the pytorch_gpu environment file directory , open the cmd window and enter the command pip install torch-1.9.0+cu111-cp36-cp36m-win_amd64.whl
to execute the pytorch installation process, and finally it prompts that the installation is successful.
|
|
|
In order to test whether the GPU version of Pytorch is successfully installed, you can enter it python
, execute the following code verification, and return True to indicate that the installation is successful.
import torch
torch.cuda.is_available()
x = torch.rand(5,5)
print(x)