(conda + pip) 配置各版本 Pytorch 深度学习环境

目录

*

+ 1. 前言
+ 2. 配置镜像源
+ 3. pytorch,torchvision,python 版本对应
+ 4. 创建并进入虚拟环境
+ 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. 测试是否安装成功

1. 前言

  • 利用 Anaconda 配置 Pytorch 深度学习环境时利用官网链接给出的安装指令安装会很慢,经常报错,为此整理目前主流版本 pytorch 深度学习环境配置指令,以下指令适用 Windows 操作系统,在 Anaconda Prompt 中运行。
  • 另外有时使用 conda 安装会报错,文中包括 pip 安装的指令,由于官网给出的 pip 安装方法多少不太友好,文中进行了一定改进,绝大部分指令亲测有效。

(conda + pip) 配置各版本 Pytorch 深度学习环境

; 2. 配置镜像源

提前说:如果配置镜像源后报 HTTP 错误,只需要将源链接中的 https://… 中的 s 删掉就行
清华源

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

中科大源

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. pytorch,torchvision,python 版本对应

pytorch,torchvision,python 三者的对应关系来源于 pytorch 官方 github,链接:https://github.com/pytorch/vision#installation

(conda + pip) 配置各版本 Pytorch 深度学习环境

; 4. 创建并进入虚拟环境

创建一个虚拟环境,其中 pt 是自定义虚拟环境名称,另外根据踩坑经验 python 3.6.5 版本可以适配比较多的 pytorch 版本和一些额外包,建议创建环境时 python 解释器版本选择 3.6.5 版本。

conda create -n pt python=3.6.5

随后点击 y 同意安装,等待一会进入虚拟环境。

activate pt

5. Pytorch 0.4.1


conda install pytorch==0.4.1 torchvision==0.2.1 cuda90
conda install pytorch==0.4.1 torchvision==0.2.1 cuda92
conda install pytorch==0.4.1 torchvision==0.2.1 cuda80
conda install pytorch==0.4.1 torchvision==0.2.1 cuda75
conda install pytorch==0.4.1 torchvision==0.2.1 cpuonly

pip install https://download.pytorch.org/whl/cu90/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cu80/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cu75/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl torchvision==0.2.1

6. Pytorch 1.0.0


conda install pytorch==1.0.0 torchvision==0.2.1 cuda100
conda install pytorch==1.0.0 torchvision==0.2.1 cuda90
conda install pytorch==1.0.0 torchvision==0.2.1 cuda80
conda install pytorch-cpu==1.0.0 torchvision-cpu==0.2.1 cpuonly

pip install https://download.pytorch.org/whl/cu100/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cu90/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cu80/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1
pip install https://download.pytorch.org/whl/cpu/torch-1.0.0-cp36-cp36m-win_amd64.whl torchvision==0.2.1

7. Pytorch 1.0.1


conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=10.0
conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=9.0
conda install pytorch-cpu==1.0.1 torchvision-cpu==0.2.2 cpuonly

pip install https://download.pytorch.org/whl/cu100/torch-1.0.1-cp36-cp36m-win_amd64.whl torchvision==0.2.2
pip install https://download.pytorch.org/whl/cu90/torch-1.0.1-cp36-cp36m-win_amd64.whl torchvision==0.2.2
pip install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp36-cp36m-win_amd64.whl torchvision==0.2.2

8. Pytorch 1.1.0


conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly

pip install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp36-cp36m-win_amd64.whl torchvision==0.3.0
pip install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl torchvision==0.3.0
pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-win_amd64.whl torchvision==0.3.0

9. Pytorch 1.2.0


conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2
conda install pytorch==1.2.0 torchvision==0.4.0 cpuonly

pip install torch==1.2.0+cu100 torchvision==0.4.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

10. Pytorch 1.4.0


conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2
conda install pytorch==1.4.0 torchvision==0.5.0 cpuonly

pip install torch==1.4.0+cu101 torchvision==0.5.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.4.0+cu92 torchvision==0.5.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

11. Pytorch 1.5.0


conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.2
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.1
conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=9.2
conda install pytorch==1.5.0 torchvision==0.6.0 cpuonly

pip install torch==1.5.0+cu102 torchvision==0.6.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.5.0+cu92 torchvision==0.6.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

12. Pytorch 1.5.1


conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.2
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.1
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=9.2
conda install pytorch==1.5.1 torchvision==0.6.1 cpuonly

pip install torch==1.5.1+cu102 torchvision==0.6.1+cu102 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.5.1+cu92 torchvision==0.6.1+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

13. Pytorch 1.6.0


conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=9.2
conda install pytorch==1.6.0 torchvision==0.7.0 cpuonly

pip install torch==1.6.0+cu102 torchvision==0.7.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.6.0+cu92 torchvision==0.7.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

14. Pytorch 1.7.0


conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=11.0
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.2
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=10.1
conda install pytorch==1.7.0 torchvision==0.8.0 cudatoolkit=9.2
conda install pytorch==1.7.0 torchvision==0.8.0 cpuonly

pip install torch==1.7.0+cu110 torchvision==0.8.0+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.0+cu102 torchvision==0.8.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.0+cu101 torchvision==0.8.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.0+cu92 torchvision==0.8.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.0+cpu torchvision==0.8.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

15. Pytorch 1.7.1


conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=11.0
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=10.2
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=10.1
conda install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=9.2
conda install pytorch==1.7.1 torchvision==0.8.2 cpuonly

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.1+cu92 torchvision==0.8.2+cu92 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html

16. Pytorch 1.8.0


conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=11.1
conda install pytorch==1.8.0 torchvision==0.9.0 cudatoolkit=10.2
conda install pytorch==1.8.0 torchvision==0.9.0 cpuonly

pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.8.0+cu102 torchvision==0.9.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.8.0+cpu torchvision==0.9.0+cpu0 -f https://download.pytorch.org/whl/torch_stable.html

17. Pytorch 1.9.0


conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=11.1
conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=10.2
conda install pytorch==1.9.0 torchvision==0.10.0 cpuonly

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.9.0+cu102 torchvision==0.10.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

18. 测试是否安装成功

  • CPU 版本测试:继续运行 python 进入交互式环境,分别运行 import torchimport torchvision 不报错则安装成功。
  • GPU 版本测试:继续运行 python 进入交互式环境,分别运行 import torchimport torchvision 不报错, 再运行 print(torch.cuda.is_available()) 输出 Ture 则表示安装成功。

(conda + pip) 配置各版本 Pytorch 深度学习环境

Original: https://blog.csdn.net/Wenyuanbo/article/details/119382460
Author: 听 风、
Title: (conda + pip) 配置各版本 Pytorch 深度学习环境

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/770267/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球