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

本文详细介绍了如何检查CUDA的安装状态,配置清华源加速下载,以及如何根据个人CUDA版本选择并安装合适的PyTorch版本。同时,提供了安装特定版本PyTorch和torchvision的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

检查自己的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官网

官网链接: https://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

如上所说,直接将cudatoolkit=10.1改为你自己的cuda版本,如我的是cuda 9.0:
在这里插入图片描述

conda install pytorch torchvision cudatoolkit=9.0  pytorch

安装就行了。

安装指定版本的pytorch

conda install pytorch cuda90 pytorch==0.4.0

根据上面的代码自己修改自己的合适的版本就好了;贴出我安装的图片:
在这里插入图片描述
可以看到是使用国内源的清华源安装的。

安装指定版本的torchvision

如果你在看代码的时候,有些时候作者要求指定版本的torch或者torchvision,这个只能在官网上下载以前版本的文件,还好torchvision比较小。
在这里插入图片描述
点击 Previous PyTorch Versions
在这里插入图片描述
上面就有你想要找到的版本对应文件,下载下来 pip install就好了。需要注意很多版本问题,如:cuda9.0的torchvison只支持到0.3.0版本等等。

验证你的pytorch安装好没有

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

python
import torch
exit()

恭喜你安装成功。

参考博客:https://blog.youkuaiyun.com/Cinderella___/article/details/88097679

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值