Table of contents
-
-
- 1 Introduction
- 2. Configure mirror source
- 3. Corresponding versions of pytorch, torchvision and python
- 4. Create and enter the virtual environment
- 5. Pytorch 0.4.1
- 6. Pytorch 1.0.0
- 7. Pytorch 1.0.1
- 8. Pytorch 1.1.0
- 9. Pytorch 1.2.0
- 10. Pytorch 1.4.0
- 11. Pytorch 1.5.0
- 12. Pytorch 1.5.1
- 13. Pytorch 1.6.0
- 14. Pytorch 1.7.0
- 15. Pytorch 1.7.1
- 16. Pytorch 1.8.0
- 17. Pytorch 1.9.0
- 18. Test whether the installation is successful
-
1 Introduction
- When using Anaconda to configure the Pytorch deep learning environment, the installation instructions given by the official website link will be very slow and errors are often reported. To this end, the current mainstream version of pytorch deep learning environment configuration instructions are compiled. The following instructions are suitable for Windows operating systems and run in Anaconda Prompt .
- In addition, sometimes when using conda to install, an error will be reported. The article includes pip installation instructions. Since the pip installation method given on the official website is somewhat unfriendly, certain improvements have been made in the article. Most of the instructions are effective in personal testing.
2. Configure mirror source
Let me tell you in advance : If an HTTP error is reported after configuring the mirror source, you only need to delete the s in https://... in the source link.
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/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --set show_channel_urls yes
Dayuan of Science and Technology of China
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
3. Corresponding versions of pytorch, torchvision and python
The corresponding relationship between pytorch, torchvision and python comes from pytorch official github, link: https://github.com/pytorch/vision#installation
4. Create and enter the virtual environment
Create a virtual environment, where pt is the name of the customized virtual environment. In addition, based on pitfall experience, python 3.6.5 version can adapt to more pytorch versions and some additional packages. It is recommended to select version 3.6.5 for the python interpreter version when creating an environment. .
conda create -n pt python=3.6.5
Then click y to agree to the installation and wait for a while to enter the virtual environment.
activate pt
5. Pytorch 0.4.1
# conda
conda install pytorch==0.4.1 torchvision==0.2.1 cuda90 # CUDA 9.0
conda install pytorch==0.4.1 torchvision==0.2.1 cuda92 # CUDA 9.2
conda install pytorch==0.4.1 torchvision==0.2.1 cuda80 # CUDA 8.0
conda install pytorch==0.4.1 torchvision==0.2.1 cuda75 # CUDA 7.5
conda install pytorch==0.4.1 torchvision==0.2.1 cpuonly # CPU 版本
# pip
pip install https://download.pytorch.org/whl/cu90/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 9.0
pip install https://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 9.2
pip install https://download.pytorch.org/whl/cu80/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 8.0
pip install https://download.pytorch.org/whl/cu75/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 7.5
pip install https://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CPU 版本
6. Pytorch 1.0.0
# conda
conda install pytorch==1.0.0 torchvision==0.2.1 cuda100 # CUDA 10.0
conda install pytorch==1.0.0 torchvision==0.2.1 cuda90 # CUDA 9.0
conda install pytorch==1.0.0 torchvision==0.2.1 cuda80 # CUDA 8.0
conda install pytorch-cpu==1.0.0 torchvision-cpu==0.2.1 cpuonly # CPU 版本
# pip
pip install https://download.pytorch.org/whl/cu100/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 10.0
pip install https://download.pytorch.org/whl/cu90/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 9.0
pip install https://download.pytorch.org/whl/cu80/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CUDA 8.0
pip install https://download.pytorch.org/whl/cpu/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1 # CPU 版本
7. Pytorch 1.0.1
# conda
conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=10.0 # CUDA 10.0
conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=9.0 # CUDA 9.0
conda install pytorch-cpu==1.0.1 torchvision-cpu==0.2.2 cpuonly # CPU 版本
# pip
pip install https://download.pytorch.org/whl/cu100/torch-1.0.1-cp36-cp36m-win_amd64.whl torchvision==0.2.2 # CUDA 10.0
pip install https://download.pytorch.org/whl/cu90/torch-1.0.1-cp36-cp36m-win_amd64.whl torchvision==0.2.2 # CUDA 9.0
pip install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp36-cp36m-win_amd64.whl torchvision==0.2.2 # CPU 版本
8. Pytorch 1.1.0
# conda
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0 # CUDA 10.0
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0 # CUDA 9.0
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly # CPU 版本
# pip
pip install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp36-cp36m-win_amd64.whl torchvision==0.3.0 # CUDA 10.0
pip install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl torchvision==0.3.0 # CUDA 9.0
pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-win_amd64.whl torchvision==0.3.0 # CPU 版本
9. Pytorch 1.2.0
# conda
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 # CUDA 10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.2.0 torchvision==0.4.0 cpuonly # CPU 版本
# pip
pip install torch==1.2.0+cu100 torchvision==0.4.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.0
pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
10. Pytorch 1.4.0
# conda
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 # CUDA 10.1
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.4.0 torchvision==0.5.0 cpuonly # CPU 版本
# pip
pip install torch==1.4.0+cu101 torchvision==0.5.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.1
pip install torch==1.4.0+cu92 torchvision==0.5.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
11. Pytorch 1.5.0
# conda
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.1 # CUDA 10.1
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.5.0 torchvision==0.6.0 cpuonly # CPU 版本
# pip
pip install torch==1.5.0+cu102 torchvision==0.6.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.1
pip install torch==1.5.0+cu92 torchvision==0.6.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
12. Pytorch 1.5.1
# conda
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.1 # CUDA 10.1
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.5.1 torchvision==0.6.1 cpuonly # CPU 版本
# pip
pip install torch==1.5.1+cu102 torchvision==0.6.1+cu102 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.1
pip install torch==1.5.1+cu92 torchvision==0.6.1+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
13. Pytorch 1.6.0
# conda
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 # CUDA 10.1
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.6.0 torchvision==0.7.0 cpuonly # CPU 版本
# pip
pip install torch==1.6.0+cu102 torchvision==0.7.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.1
pip install torch==1.6.0+cu92 torchvision==0.7.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
14. Pytorch 1.7.0
# conda
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=11.0 # CUDA 11.0
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.1 # CUDA 10.1
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.7.0 torchvision==0.8.0 cpuonly # CPU 版本
# pip
pip install torch==1.7.0+cu110 torchvision==0.8.0+cu110 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 11.0
pip install torch==1.7.0+cu102 torchvision==0.8.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.7.0+cu101 torchvision==0.8.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.1
pip install torch==1.7.0+cu92 torchvision==0.8.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.7.0+cpu torchvision==0.8.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
15. Pytorch 1.7.1
# conda
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=11.0 # CUDA 11.0
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=10.1 # CUDA 10.1
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=9.2 # CUDA 9.2
conda install pytorch==1.7.1 torchvision==0.8.2 cpuonly # CPU 版本
# pip
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 11.0
pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.1
pip install torch==1.7.1+cu92 torchvision==0.8.2+cu92 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 9.2
pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
16. Pytorch 1.8.0
# conda
conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=11.1 # CUDA 11.1
conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.8.0 torchvision==0.9.0 cpuonly # CPU 版本
# pip
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 11.1
pip install torch==1.8.0+cu102 torchvision==0.9.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.8.0+cpu torchvision==0.9.0+cpu0 -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
17. Pytorch 1.9.0
# conda
conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=11.1 # CUDA 11.1
conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=10.2 # CUDA 10.2
conda install pytorch==1.9.0 torchvision==0.10.0 cpuonly # CPU 版本
# pip
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 11.1
pip install torch==1.9.0+cu102 torchvision==0.10.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html # CUDA 10.2
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html # CPU 版本
18. Test whether the installation is successful
- CPU version test: Continue running python to enter the interactive environment and run them separately
import torch
.import torchvision
If no error is reported, the installation is successful. - GPU version test: Continue running python to enter the interactive environment, run them separately without
import torch
reportingimport torchvision
an error, and run againprint(torch.cuda.is_available())
. If True is output, the installation is successful.