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 --set show_channel_urls yes
pytorch,torchvision,python 三者的对应关系来源于 pytorch 官方 github,链接:https://github.com/pytorch/vision#installation
创建一个虚拟环境,其中 pt 是自定义虚拟环境名称,另外根据踩坑经验 python 3.6.5 版本可以适配比较多的 pytorch 版本和一些额外包,建议创建环境时 python 解释器版本选择 3.6.5 版本。
conda create -n pt python=3.6.5
随后点击 y 同意安装,等待一会进入虚拟环境。
activate pt
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
# 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 版本
import torch
,import torchvision
不报错则安装成功。import torch
,import torchvision
不报错, 再运行 print(torch.cuda.is_available())
输出 Ture 则表示安装成功。