Teach you step by step how to use anaconda to install the pytorch environment (suitable for novices)

1. First check if there is any problem with your graphics card driver.

If you right-click the computer and there is (nvidia control panel), do not do the following

If not, you need to perform the following operations

(Right-click this computer, find Management and open it)

Find device manager

Find the display adapter (your graphics card model will be here)

Based on the above information, we can go to the NVIDIA official website to find the corresponding graphics card driver update or download for our graphics card.

Graphics card driver download address

After installing the graphics card driver, we press the win+R key combination to open the cmd command window and enter the following command

nvidia-smi

You can see that the driver version is 527.56; the highest supported CUDA version is version 12.0. We can install the environment based on this information.

2. Installation of anaconda

Go to the official website to download the anaconda installation package Anaconda | Anaconda Distribution

Install

Remember to select this step (add)

In this way, our anaconda is installed

3. Installation of pytorch

Enter the anaconda prompt

Execute code

conda env list

After executing the code, you can see the virtual environment you created under anaconda (this is what I have created including paddle, pytorch, etc.)

If you install it for the first time, you will only have a base environment.

At this time we create our own pytorch environment (here we can specify the python version number, for example, mine is python3.9)

conda create -n pytorch python=3.9

It will ask you to configure the corresponding environment package and enter y (y represents yes)

At this time, our pytorch environment has been established, but we need to go in and configure the corresponding packages for deep learning.

First we have to go into the pytorch environment

conda activate pytorch

Downloading related environment packages is relatively slow, so we change the source of the environment. In the pytorch environment, execute the following naming to change the environment to Tsinghua source.

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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

At this time we open the official website of pytorch ( PyTorch ) and select our version

Copy it and execute it in our pytorch environment

conda install pytorch torchvision torchaudio pytorch-cuda=11.7

因为我们刚刚进行了换源,不需要把后面的-c pytorch -c nvidia复制过来,那样下载速度会很慢,然后慢慢下载就好啦!

Guess you like

Origin blog.csdn.net/qq_54575112/article/details/128491493