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~
Article directory
1. Anaconda installation
1.1 download
First, enter the Aanconda download address: https://www.anaconda.com/download/
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/
1.2 Installation
After the download is complete, we click the installation package to start the installation.
Here you can change the installation path to the D drive, the default is the C drive.
The installation time of the latest version is a bit long, just wait quietly.
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 “环境变量”
.
After configuring the environment, let's test it.
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+R
and enter cmd to enter the terminal. Use the command: nvidia-smi
Check
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
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.
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.
Then the installation steps are shown in the following figure in turn:
the installation is completed in the above figure, just click to close.
Next, we can nvcc -V
verify whether the installation is successful through the terminal command.
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
I won’t go into details about logging in. It’s very simple. Just enter your email address and click. Next
After 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.
3.2 cuDNN configuration (also can be regarded as paste coverage)
After the download is complete, unzip it, then copy the content bin、include
and lib
directory inside, and then move to the Cuda installation directory, as shown in the figure below:
Enter the directory: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7
:
and paste it.
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:
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 PyTorch
to install the old version.
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 list
view the installed virtual environment through the command.
4.2 pytorch installation
After the virtual environment is created, we use the command conda activate pytorch
to enter the pytorch virtual environment.
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.
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()
Return True to prove that the installation is successful. At this time, we can start our deep learning journey~