1. 前言
利用 anaconda 配置 pytorch 深度学习环境时利用官网链接给出的安装指令安装会很慢,而且经常报错,为此整理目前全版本 pytorch 深度学习环境配置指令,以下指令适用 windows 操作系统,在 anaconda prompt 中运行。
2. 配置镜像源
1
2
3
4
5
|
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,链接:https://github.com/pytorch/vision#installation
4. 创建并进入虚拟环境
创建一个虚拟环境,其中 pt 是自定义虚拟环境名称,另外根据踩坑经验 python 3.6.5 版本可以适配所有版本的 pytorch,建议创建环境时 python 解释器版本选择 3.6.5 版本。
1
|
conda create - n pt python = 3.6 . 5
|
随后点击 y 同意安装,等待一会进入虚拟环境。
1
|
activate pt
|
5. pytorch 0.4.1
1
2
3
4
5
|
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
1
2
3
4
|
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
1
2
3
|
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
1
2
3
|
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
1
2
3
|
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
1
2
3
|
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
1
2
3
4
|
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
1
2
3
4
|
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
1
2
3
4
|
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
1
2
3
4
5
|
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
1
2
3
4
5
|
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
1
2
3
|
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
1
2
3
|
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 torch
,import torchvision
不报错则安装成功。 -
gpu 版本测试:继续运行 python 进入交互式环境,分别运行
import torch
,import torchvision
不报错, 再运行print(torch.cuda.is_available())
输出 ture 则表示安装成功。
到此这篇关于anaconda配置各版本pytorch的实现的文章就介绍到这了,更多相关anaconda配置pytorch内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://blog.csdn.net/Wenyuanbo/article/details/119382460