[RTX 3060Ti deep learning environment configuration graphics (install Anaconda, VScode, CUDA, CUDNN, pytorch)]

configuration

The author configures it as a desktop 3060ti, and the environment is cuda11.4, cudnn8.2, pytorch1.9, python3.9

install driver

Install the latest graphics card driver, NVIDIA graphics driver website https://www.nvidia.cn/geforce/drivers/
Find your own graphics card model, download and install
Enter the graphics card model to distinguish between desktop and notebook
Enter the graphics card model to distinguish between desktop and notebook

1. Install Anaconda

1.1 Introduction to Anaconda

Anaconda is a packaged collection, which is pre-installed with conda, a certain version of python, many packages, scientific computing tools, etc., so it is also called a distribution of Python. Because it contains a large number of packages, Anaconda's download file is relatively large (about 786 MB). If you only need some packages, or need to save bandwidth or storage space, you can choose Miniconda. As the name suggests, it only contains the most basic content—— Python and conda, and related necessary dependencies, for users with strict space requirements, Miniconda is an option.
Conda can be understood as a tool and an executable command. Its core function is package management and environment management. Package management is similar to the use of pip, and environment management allows users to easily install different versions of python and switch quickly.

1.2 Download Anaconda

Anaconda official website download address: https://www.anaconda.com/download/
Click Download to start downloading, the download speed is slow, wait patiently
Click Download to download
Click Next

1.3 Install Anaconda

Click Next
Click I agree,
Click I agree
select Just Me, and click Next
Select Just Me and click Next
to change the installation address. Here, the installation is on the D drive.
Change the installation address, here it is installed on the D drive
It is recommended to check all of them here. The second item is to add environment variables, and the fourth item is to clean up the package after the installation is complete without affecting the use and wait for
It is recommended to check all of them here. The second item is to add environment variables, and the fourth item is to clean up the package after the installation is complete without affecting the use.
installation . Complete
Wait for the installation to complete
This means that the installation is complete, click Next
This indicates that the installation is complete, click Next.
, click Next,
Click Next
and click Finish to complete the installation
Click Finish to complete the installation

1.4 Configure environment variables

1.4.1 Add environment variables

Let’s take win10 as an example.
Select Settings from the start menu bar in the lower right corner of the computer. After clicking, find About.
set up
Click About. In the upper right corner, select Advanced System Settings. Click
about
Advanced System Settings
win10
. Select Environment Variables . Add these three paths to the path environment variable
Advanced System Settings

select path

environment variable

1.4.2 Testing

Test whether Anaconda is installed successfully
Open Anaconda and enter conda --versiontest

2. Install VScode

2.1 Introduction to VScode

VisualStudioCode (VSCode for short) is a code editor developed by Microsoft that supports operating systems such as Windows, Linux, and macOS as well as open source code.
VScode integrates all the features that a modern editor should have, including syntax highlighting, customizable hotkey bindings, bracket matching, and code snippet collection.
It supports testing and has built-in Git version control features as well as development environment features such as code completion (similar to IntelliSense), code snippets and code refactoring, etc.
The editor supports user-customized configuration, such as various properties and parameters that can be changed while still in the editor, such as theme colors, keyboard shortcuts, etc., built-in extension management functions.

2.2 VScode download

VScode official website https://code.visualstudio.com/

2.3 VScode installation


After the download is complete, open the extension bar on the left side of VScode to search for Chinese, click install, restart after the installation is complete, and the Chinese page will be displayed
Chinese
. Continue to search for Python, and click install to install.
python
It is recommended to install VScode first and then install CUDA and CUDNN

3. Install CUDA and CUDNN

3.1 Introduction to CUDA

CUDA is a parallel computing platform and programming model invented by NVIDIA. It dramatically increases computing performance by harnessing the processing power of a graphics processing unit (GPU).
With millions of CUDA-based GPUs sold to date, software developers, scientists, and researchers are using CUDA in a variety of fields, including image and video processing, computational biology and chemistry, fluid dynamics simulations, and CT image reconstruction , seismic analysis, ray tracing, and more

3.2 CUDA download

CUDA official download link, find the version that suits you
https://developer.nvidia.com/cuda-toolkit-archive , the author here is version 11.4.0
and install it after downloading
insert image description here

3.3 CUDA installation

This path is a temporary folder. After the installation is complete, this folder will be deleted
. The default is fine. Here, a temporary folder is created on the D drive for operation. Click OK and
temporary folder
wait for the installation to complete
Install
. The official installation starts, click Agree and continue,
Start the official installation
select Custom here
Choose custom here
You can check all of them here to
custom install
start selecting the installation path. Here the default is the C drive, here the author changed it to the D drive, install the three files in the NVIDIA CUDA folder, click Next and click Next to
installation path
check
click next
, Click Next
check here
. Here is the installation process. Wait for a few minutes to
Installation process
complete the installation. Here is the installation information. Just click Next
The installation is complete
and click Close.
Finish
At this point, CUDA is installed successfully. If you are not at ease, you can test it
and open the command prompt. , enter cmd
cmd
and enter nvcc -V, the output is as follows, the installation is successful. If
insert image description here
you are not at ease, you can enter the environment variable to check whether there is CUDA. If there is, it means that the installation is successful.
insert image description here
Next is the installation of CUDNN

3.4 Installation of CUDNN

CUDNN official download address: https://developer.nvidia.cn/zh-cn/cudnn
Before downloading, you need to register the account email address. After the registration is complete, you can download it. Click Archived CUDNN releases here. Here the author chooses version
insert image description here
8.2 Download the fourth Windows version
insert image description here
Click to enter, find the version that meets your requirements to download, and decompress after the download is complete
unzipped file
Copy the decompressed file to the folder where CUDA was just installed. CUDA installation path
At this point, CUDA and CUDNN are successfully installed .

Fourth, the installation of Pytorch

4.1 Create a virtual environment

Open Anaconda to create a virtual environment.
insert image description here
Enter conda create -n pytorch python=3.9
where pytorch is the environment variable name, or other English letter combinations, such as pytch and
Create a virtual environment
press Enter to execute the command
Installation package directory
. Here is the installation directory of the installation package. Enter y, click Enter
download
and wait for the download, after the download is complete, you can activate the virtual environment just created

4.2 Activate the virtual environment

Activate the virtual environment
Enter conda install cudatoolkit to download
download cudatoolkit
Enter y, click Enter to download, wait patiently for the download to complete
download
Wait for the download to complete

4.3 Install pytorch

Type: pip install torch1.9.0+cu111 torch vision0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
Click Enter and wait for the download. If the network is not good, an error may be reported. You can choose to execute the command several times Can be installed successfully
download package
After the download is complete, you can close the window and test

4.4 Testing

Open anaconda to activate the environment just created. The environment created by the author is called pytorch.
After entering the environment, enter python, press Enter
and then enter import torch, press Enter and
enter torch.version (note that there are two consecutive underscores in front) and
no error is reported For successful installation
, enter torch.cuda.is_available()
and the output must be True. If the output is True, it means that the installation has been completed successfully.
test
Exit the environment, enter exit()
quit
The above is the configuration process of the entire virtual environment.

Guess you like

Origin blog.csdn.net/m0_64384233/article/details/129913188#comments_27317341