win10使用清华源快速安装指定版本的pytorch-GPU

检查自己的cuda是否安装好

在anaconda prompt中输入

nvcc -V

在这里插入图片描述
显示如上面表示安装好了。

配置清华园下载环境

同样在在anaconda prompt中输入

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/conda-forge/ 
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ 
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
 
conda config --set show_channel_urls yes

然后在:C:\Users\Administrator 目录下的 .condarc 文件,打开文件删除defaults那一行。如下图所示:
win10使用清华源快速安装指定版本的pytorch-GPU_第1张图片

点击进入pytorch官网

官网链接: https://pytorch.org/get-started/locally/.
自己选择自己的版本,如下:
win10使用清华源快速安装指定版本的pytorch-GPU_第2张图片
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
这行代码的含义是:安装pytorch时会把torchvision也给安装上,就不用后面再安装torchvision了。cudatoolkit=10.1表示cuda版本10.1。-c表示使用官网下载。不含-cpu表示gpu版。

配置自己cuda版本的pytorch

如上所说,直接将cudatoolkit=10.1改为你自己的cuda版本,如我的是cuda 9.0:
win10使用清华源快速安装指定版本的pytorch-GPU_第3张图片

conda install pytorch torchvision cudatoolkit=9.0  pytorch

安装就行了。

安装指定版本的pytorch

conda install pytorch cuda90 pytorch==0.4.0

根据上面的代码自己修改自己的合适的版本就好了;贴出我安装的图片:
win10使用清华源快速安装指定版本的pytorch-GPU_第4张图片
可以看到是使用国内源的清华源安装的。

安装指定版本的torchvision

如果你在看代码的时候,有些时候作者要求指定版本的torch或者torchvision,这个只能在官网上下载以前版本的文件,还好torchvision比较小。
win10使用清华源快速安装指定版本的pytorch-GPU_第5张图片
点击 Previous PyTorch Versions
win10使用清华源快速安装指定版本的pytorch-GPU_第6张图片
上面就有你想要找到的版本对应文件,下载下来 pip install就好了。需要注意很多版本问题,如:cuda9.0的torchvison只支持到0.3.0版本等等。

验证你的pytorch安装好没有

在这里插入图片描述
这样就安装好了。

python
import torch
exit()

恭喜你安装成功。

参考博客:https://blog.csdn.net/Cinderella___/article/details/88097679

你可能感兴趣的:(深度学习环境配置,pytorch-gpu安装)