赞
踩
cuda11.0+pytorch1.7.1
具体的可以见:
https://blog.csdn.net/weixin_41891632/article/details/126583538?spm=1001.2014.3001.5502
https://pytorch.org/get-started/previous-versions/
conda安装方式:
我的cuda版本是11.0的。要安装的pytorch是1.7.1的,直接找到对应的命令,复制下来:
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
这里如果用-c后面的默认源,安装会很慢,可以换源:
打开这个网址:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
选择自己的系统:
我这里是win10,64位:
点开之后,复制这个网址,替换掉上面的-c后面内容:将-c pytorch更改为:
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
另外一种安装方式是pip安装,我这里用的是这种方式:
直接找到对应的pip安装命令,复制,我默认用的这个官方源,下载速度也还可以
在自己conda创建的环境中运行安装就行,我之前创建了一个tf2.4环境,在里面运行,安装成功
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
代码如下(示例):
python import torch print(torch.__version__) print(torch.version.cuda) print(torch.backends.cudnn.version()) torch.cuda.is_available() #cuda是否可用; torch.cuda.device_count() #返回gpu数量; torch.cuda.get_device_name(0) #返回gpu名字,设备索引默认从0开始; torch.cuda.current_device() #返回当前设备索引
备注:
1、安装pytorch可以参考官网:https://pytorch.org/get-started/previous-versions/
2、python中安装cv2太慢:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
3、安装Notepad++: https://notepad-plus.en.softonic.com/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。