目录
  • 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

1. 前言

利用 anaconda 配置 pytorch 深度学习环境时利用给出的安装指令安装会很慢,而且经常报错,为此整理目前全版本 pytorch 深度学习环境配置指令,以下指令适用 windows 操作系统,在 anaconda prompt 中运行。

2. 配置镜像源

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/conda-forge 
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

3. pytorch,torchvision,python 版本对应

pytorch,torchvision,python 三者的对应关系来源于 pytorch 官方 github,链接:

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  # 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 版本

6. pytorch 1.0.0

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 版本

7. pytorch 1.0.1

conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=9.0  # cuda 9.0
conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=10.0  # cuda 10.0
conda install pytorch-cpu==1.0.1 torchvision-cpu==0.2.2 cpuonly  # cpu 版本

8. pytorch 1.1.0

conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=9.0  # cuda 9.0
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0  # cuda 10.0
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly  # cpu o版本

9. pytorch 1.2.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 cudatoolkit=10.0  # cuda 10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cpuonly  # cpu 版本

10. pytorch 1.4.0

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 cudatoolkit=10.1  # cuda 10.1
conda install pytorch==1.4.0 torchvision==0.5.0 cpuonly  # cpu 版本

11. pytorch 1.5.0

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 cudatoolkit=10.1  # cuda 10.1
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 cpuonly  # cpu 版本

12. pytorch 1.5.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 cudatoolkit=10.1  # cuda 10.1
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 cpuonly  # cpu 版本

13. pytorch 1.6.0

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 cudatoolkit=10.1  # cuda 10.1
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 cpuonly  # cpu 版本

14. pytorch 1.7.0

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 cudatoolkit=10.1  # cuda 10.1
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=11.0  # cuda 11.0
conda install pytorch==1.7.0 torchvision==0.8.0 cpuonly  # cpu 版本

15. pytorch 1.7.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 cudatoolkit=10.1  # cuda 10.1
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=11.0  # cuda 11.0
conda install pytorch==1.7.1 torchvision==0.8.2 cpuonly  # cpu 版本

16. pytorch 1.8.0

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 cudatoolkit=11.1  # cuda 11.1
conda install pytorch==1.8.0 torchvision==0.9.0 cpuonly  # cpu 版本

17. pytorch 1.9.0

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 cudatoolkit=11.1  # cuda 11.1
conda install pytorch==1.9.0 torchvision==0.10.0 cpuonly  # cpu 版本

18. 测试是否安装成功

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

到此这篇关于anaconda配置各版本pytorch的实现的文章就介绍到这了,更多相关anaconda配置pytorch内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!