win10使用清华源快速安装pytorch-GPU版(推荐)

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

win10使用清华源快速安装pytorch-GPU版(推荐)

  2021-04-02 我要评论

检查自己的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那一行。如下图所示:


在这里插入图片描述

点击进入pytorch官网

官网链接:  http://pytorch.org/get-started/locally/.

自己选择自己的版本,如下:


在这里插入图片描述

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

这行代码的含义是:安装pytorch时会把torchvision也给安装上,就不用后面再安装torchvision了。cudatoolkit=10.1表示cuda版本10.1。-c表示使用官网下载。不含-cpu表示gpu版。

配置自己cuda版本的pytorch,cuda版本过低怎么办

如上所说,直接将cudatoolkit=10.1改为你自己的cuda版本,如我的是cuda 9.0:


在这里插入图片描述

conda install pytorch torchvision cudatoolkit=9.0 pytorch

安装就行了。

安装指定版本的torchvision

如果你在看代码的时候,有些时候作者要求指定版本的torch或者torchvision,这个只能在官网上下载以前版本的文件。


在这里插入图片描述

点击 Previous PyTorch Versions


在这里插入图片描述

上面就有你想要找到的版本对应文件,下载下来 pip install就好了。需要注意很多版本问题,如:cuda9.0的torchvison只支持到0.3.0版本等等。

验证你的pytorch安装好没有

在这里插入图片描述

这样就安装好了。

python
import torch
exit()

恭喜你安装成功。

总结

以上所述是小编给大家介绍的win10使用清华源快速安装pytorch-GPU版,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们