Pytorch installation 20221029

This installation failed many times before it was successful, and the operation after thinking about it is basically the same as this installation. I don’t know why torch.cuda.is_available() is always False. The only difference is that the Anaconda installed in the failure is the python3.8 version. After many failures, uninstall Anaconda and all related files, reinstall Anaconda and python, and then follow the steps below to install successfully.

1. Download Anaconda

Since the download from the official website is inconvenient and slow, I choose to download the image source from Tsinghua Mirror Network, Tsinghua Anaconda image source .

The download version is as follows: (Did not download the latest version, this version comes with python3.7)

Install normally after downloading (do not check the option "Automatically add path", after the installation is complete, add it in the environment variable by yourself) 

Environment variable location: Settings - System Information - Advanced System Settings - Environment Variables - System Variables - path

Add content:

2. Check the CUDA version of the computer

View path: NVIDIA Settings - Help - System Information - Components

Support CUDA11.6 and below

3. Create and activate the PyTorch environment in Anoconda Prompt

Search to find Anaconda Prompt to open, enter on the command line:

conda create -n PyTorch python=3.8

 Pytorch is the name of the created environment, python is followed by the python version of your computer (you can open the command line through win+R and enter python to view the version)

Enter in the Anaconda Prompt command line:

conda activate PyTorch

Enter the environment: you can see that base becomes Pytorch

4. Add Tsinghua mirror source URL

Open the Anaconda Prompt command line and enter:

conda config --set show_channel_urls yes

 Then see it in the C drive - user directory.condarc文件生成,将内部内容改成如下内容:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

As shown in the picture:

 

Enter in the Anaconda Prompt command line: conda clean -i to clear the cache and ensure that you are using a mirror website. (or launch and re-enter)

5. Install PyTorch

Enter the official website: PyTorch

 

Select the corresponding version of CUDA and below . You can also download historical versions in the lower left corner.

Go to the Anaconda Prompt command line - activate the PyTorch environment , paste the link provided by the official website, the content below the picture above, as follows:

Wait for the download to complete as follows:

6. Whether the test is successful

At this point, it can be seen that the GPU version of PyTorch is installed successfully. 

Guess you like

Origin blog.csdn.net/qq_42433311/article/details/127590806