The configuration of NVIDIA+CUDA+cudaNN and the construction of Anaconda virtual environment -- the first step of deep learning

Target:

1. Start from scratch, build a deep learning environment step by step
2. Implement a deep learning network training environment suitable for python language

The specific content and overall process are as follows:
1. NVIDIA graphics card installation and cuda configuration installation;
2. Virtual environment Anaconda3 construction;
3. Test implementation torch1.4+gpu;
4. Install IDE: pycharm.
insert image description here

begin~


cuda and cuDNN configuration for NVIDIA graphics cards:

Tip: Here we take NVIDIA GeForce RTX 3060 under win10 as an example to describe the installation.

First of all: Find a place to check the graphics card information, NVIDIA Control Panelbecause you need to know which version of cuda to download to match it.
insert image description here
Find the "System Information" in the NVIDIA control panel, and find the version information: 472.12
insert image description here
click "Components" to find the corresponding version data.
insert image description here
The figure above shows that the version we need here is cuda11, so click to download at the download address CUDA Toolkit : https://developer.nvidia.com/cuda-toolkit-archive.
insert image description here
According to the system and graphics card information, select the matching version to download.
insert image description here
Just install it for fools.
After the installation is complete:
insert image description here
Installing cuda is equivalent to building a bridge on the graphics card hardware that we can use a custom program to use the graphics card to do calculations (in my opinion). GPU Computing SDK,
GPU computing toolkit is a toolkit for computing.
Here you also need to configure the supporting cuDNN.
cuDNN data download : https://developer.nvidia.com/rdp/cudnn-archive
insert image description here
insert image description here

The above involves registration and other operations, just use the email to register and verify.
Download cuDNN and unzip it.
insert image description here
Then copy the content of the files in the decompressed cuda file to the corresponding locations under the installation directory C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4.
insert image description here
Finally, environment variables need to be set.
Enter My Computer – right click on the blank space – click Properties – enter the system – click Advanced System Settings – find environment variables in the displayed system properties – enter environment variable settings – set path
insert image description here

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\libnvvp

insert image description here
Add environment variables:
insert image description here
insert image description here

Finally, test the graphics card installation results.

命令行输入:
nvcc -V
显示安装信息如下:安装成功。

insert image description here

Summary : The above installation and configuration are completed, indicating that this machine can be used for GPU computing.
The later versions of deep learning frameworks (pytorch, tensorflow, paddle, etc.) and cuda (7, 8, 9, 10, 11) are collocations in the virtual environment, which are distinguished from the previous hardware versions. The two do not need to be consistent, and the hardware is usually It meets the software requirements. Someone got into such a vicious circle before. The graphics card requires the installation of cuda tooltik11, and the deep learning framework pytorch1.4 matches cuda10. Should I download cuda tooltik10 and install it? Actually, it is not necessary. Because the pytorch1.4 mentioned later matches the cuda10 library, you can download it and transfer it to the environment. The previous hardware is satisfactory. Share a download address
of the framework pytorch and GPU matching : https://download.pytorch.org/whl/torch_stable.html, very easy to use, especially when the online installation is not smooth, or when you need to clarify the version matching problem. For example: I want pytorch1.5, window10, I can find the corresponding version and cuda, and download the .whl file directly. Install the whl file and use it directly , just press Enter.
pip install 目录下/xxx.whl
insert image description here


Anaconda virtual environment installation

Tip: The purpose of installing Anaconda is to create, replace and use the virtual environment envs at any time when using python jobs later, which is very convenient.

Download from the official website and install according to the prompts.
insert image description here
Among them, the key step:
insert image description here
after the installation is complete , you can create a customized virtual environment. There are two ways to create a virtual environment: interface creation and command line creation. For details, see: How to use anaconda to create an environment .
Our commonly used anaconda tools are also these two: anaconda navigator supports interface operations, and anaconda prompt supports command installation and modification.
insert image description here
Note: If there is a flashback when opening, it may be due to insufficient user rights, and installation on the C drive is easy to occur. Please right click to open with administrator privileges.

Here is an example command operation test :
insert image description here

1. Create an environment named virtualTorch14: conda create -n virtualTorch14 python=3.6
2. You need to install numpy to call it normally.
3. First find the matching version of pytorch1.4 and download the whl file.
Note, if you need to find the previous version of the torch framework, please go to the official website, previous pytorch versions .
Download the file: torch-1.4.0+cu92-cp36-cp36m-win_amd64.whl, to the previously mentioned combined whl file address : https://download.pytorch.org/whl/torch_stable.html.
The environment installation of virtualTorch14: first switch to this environment, activate virtualTorch14
and then install: pip install 某目录下/torch-1.4.0+cu92-cp36-cp36m-win_amd64.whl
install numpy:pip install numpy

Test whether pytorch1.4 and gpu can be used under python: the test is successful!
Test code:

import torch
print(torch.__version__)
torch.cuda.is_available()

insert image description here

pycharm installation

Download the community free version from the official website.
insert image description here

insert image description here
Install according to the prompts, note: select the associated .py file in the middle, anaconda, whether to add environment variables, etc., select Select All.
Finally, choose whether to restart according to the situation.
The installation is complete!

Let's start creating your first project.
1. Create a project;
2. Test whether pytorch14 and gpu are available.
3. Output the result.

Create an engineering project, set the project name "pythonProject" – create the environment under the project Location, choose to use the virtualTorch14 created under anaconda before. How to find: Click create create insert image description here
:
insert image description here
Create
insert image description here
a code directory and add a .py file.
Right-click on the project name – new – directory Directory – name code
insert image description here

insert image description here
Right-click on the file name – new – python file – name testGPU
insert image description here
code writing, run
insert image description here

An error was reported, I forgot to install numpy.
insert image description here
debug
Click file-select settings to open and view the first python interpreter under project:pythonProject, there is no numpy in the expanded installation library directory.

insert image description here
Commonly used libraries can be installed online without trouble. Add – enter library name – view information – select version – click install install package
insert image description here
installation is successful, there will be a green background prompt, and a red prompt for failure.
insert image description here
Close the pop-up box, ok. Run again.
insert image description here
Result: The test was successful.
over!
You have successfully taken a big step! Give yourself a thumbs up!

Guess you like

Origin blog.csdn.net/beauthy/article/details/122985684