The latest version of Anaconda environment configuration, Cuda, cuDNN and pytorch environment one-click configuration process

This tutorial is the latest deep learning entry environment configuration tutorial. Following this tutorial can help you solve the environment configuration problems before getting started with deep learning. At the same time, this tutorial refuses to be trivial, and most of the tutorials are in the form of illustrations. Here we install the latest version~

1. Anaconda installation

1.1 download

First, enter the Aanconda download address: https://www.anaconda.com/download/

insert image description here

If you think the download is slow, you can also use the software mirror website of Tsinghua University: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
insert image description here

insert image description here

1.2 Installation

After the download is complete, we click the installation package to start the installation.
insert image description here
insert image description here
insert image description here
insert image description here
Here you can change the installation path to the D drive, the default is the C drive.
insert image description here
insert image description here
The installation time of the latest version is a bit long, just wait quietly.

insert image description here
insert image description here
Uncheck the above two, otherwise the website and the Anaconda navigation tool will be opened.

1.3 Environment configuration

The steps are as follows: 此电脑----->属性----->高级系统设置----->环境变量----->path----->编辑----->新建(Many software configure environment variables here, you should be familiar with it), if you are too lazy, just press the win key to search “环境变量”.
insert image description here
insert image description here
insert image description here
insert image description here
After configuring the environment, let's test it.
insert image description here
Returning the version indicates that the configuration has been successful.

2. Cuda installation

2.1 View cuda version

Before installing cuda, we must first check whether our computer has a discrete graphics card. If so, we need to check the version of cuda.
You can hold down the keyboard Win+Rand enter cmd to enter the terminal. Use the command: nvidia-smiCheck
insert image description here
it out, remember your own version number, because when we install cuda, we need to install the 不高于cuda version with this version number.

2.2 cuda installation package download

According to my cuda version is 12.1, then I can install a version below 12.1, but not too low.
First, enter the download address: https://developer.nvidia.com/cuda-toolkit-archive
insert image description here
Here, I choose to install version 11.7, click on the front CUDA Toolkit 11.7.0, remember to click on the red box in the above picture, and you will jump after clicking to another document interface.
insert image description here

2.3 cuda installation

After clicking on the picture above to install, the installation package will be downloaded. If the network speed is not good, it will take a long time.
After the download is complete, click Install.
After clicking the installation package, a prompt as shown in the figure below will pop up first, just click OK, and there is no need to change the path.
insert image description here
Then the installation steps are shown in the following figure in turn:
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
the installation is completed in the above figure, just click to close.
Next, we can nvcc -Vverify whether the installation is successful through the terminal command.
insert image description here

Three, cuDNN installation

The installation of cuDNN also requires the corresponding version of Cuda. At the same time, when we enter the official website, we need to log in to our account, because cuDNN can only be downloaded after logging in to the account.
Installation package download address : https://developer.nvidia.com/rdp/cudnn-download
insert image description here
I won’t go into details about logging in. It’s very simple. Just enter your email address and click. NextAfter entering, you can choose WeChat to log in, and then enter the email verify.

3.1 cuDNN installation package download

After entering the download website, the following interface will appear, we can choose the corresponding version of cuDNN of our own Cuda to expand and download.
insert image description here

3.2 cuDNN configuration (also can be regarded as paste coverage)

After the download is complete, unzip it, then copy the content bin、includeand libdirectory inside, and then move to the Cuda installation directory, as shown in the figure below:
insert image description here
Enter the directory: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7:
insert image description here
and paste it.
insert image description here

Once the pasting is complete, it's done. At this time, we can delete all the previous installation packages.

Four, Pytorch installation

First, enter the official website of Pytorch: https://pytorch.org/
and then slide down, as shown in the figure below:
insert image description here
You can see that the latest versions 11.7 and 11.8 are available on the official website. Here, since we are installing cuda version 11.7, we can directly copy the above command and install it in the Anaconda virtual environment.

# CUDA 11.7 安装命令:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

If the CUDA version is too low and you want to install the previous version, you can click below Previous versions of PyTorchto install the old version.
insert image description here
insert image description here

4.1 Creation of pytorch virtual environment in Anaconda

When installing, we can first create a pytorch virtual environment in Anaconda, the command is as follows:

conda create -n pytorch python=3.7

It is recommended to install python 3.7 or 3.8 here, which is more stable.

After creating the virtual environment, we can conda env listview the installed virtual environment through the command.
insert image description here

4.2 pytorch installation

After the virtual environment is created, we use the command conda activate pytorchto enter the pytorch virtual environment.
insert image description here
When you see that the base (basic environment) in the left brackets has changed to the pytorch environment, it means that the activation of the virtual environment is successful.

At this time, we can directly enter the installation command copied from the pytorch official website to install it.
insert image description here
The installation speed here is also different according to each person's network speed, and it takes a while to wait.
After the installation is complete, we can enter the python command to enter the python compiler.
Enter the following command to verify that the installation was successful:

import torch
torch.cuda.is_available()

insert image description here
Return True to prove that the installation is successful. At this time, we can start our deep learning journey~

Guess you like

Origin blog.csdn.net/m0_63007797/article/details/132244275