Pytorch study notes 1.2: Pytorch environment installation

Pytorch environment installation

Insert picture description herePytorch official website
Choose the version you want to use.
Insert picture description hereSince the direct installation of pytorch in China will be slow and error-prone, the installation speed of Tsinghua mirror is generally much faster. The detailed steps are directly quoted from here: https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

Tsinghua's Pytorch mirror is strongly recommended! ! !

One, modify the .condarc file

Find the .condarc file in the "C:\Users\Username" directory, and copy the following content to this file. If you don't have this file, you can execute conda config --set show_channel_urls yes to generate the file and then modify it.

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

Second, execute the installation command

Find the installation command of the corresponding version from the pytorch official website. Here I installed pytorch1.7, windows 10, cuda 10.1, python version, execute the following command in Anaconda power shell:

conda install pytorch torchvision torchaudio cudatoolkit=10.1 -c pytorch

Install it in a few minutes!
If you have previously installed it, you may get an error, possibly because of the files left over from the previous installation failure. You can delete the corresponding file or folder under C:\Users\Administrator\anaconda3\pkgs as prompted, and then execute the installation command again.

InvalidArchiveError(‘Error with archive
C:\Users\Administrator\anaconda3\pkgs\torchvision-0.8.1-py38_cu101.tar.bz2.
You probably need to delete and re-download or re-create this file.
Message from libarchive was:\n\nCould not unlink’)

InvalidArchiveError(‘Error with archive
C:\Users\Administrator\anaconda3\pkgs\pytorch-1.7.0-py3.8_cuda101_cudnn7_0.tar.bz2.
You probably need to delete and re-download or re-create this file.
Message from libarchive was:\n\nCould not unlink’)

Guess you like

Origin blog.csdn.net/weixin_44145452/article/details/113027520