大家好,又见面了,我是你们的朋友全栈君。
cudnn安装:
cp cudnn-8.0-linux-x64-v5.1.solitairetheme8 cudnn-8.0-linux-x64-v5.1.tgz
tar -xvf cudnn-8.0-linux-x64-v5.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
sudo ldconfig
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
打开官网,找到对应合适的版本(cuda): https://pytorch.org/get-started/locally/
之后复制下面这一行指令: conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch
把-c pytorch表示的pytorch源,更改为国内的镜像。
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
先浏览器打开这个网页,然后选择你的系统
点开之后复制这个新地址,将-c pytorch更改为
conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/
检验步骤:
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()
#返回当前设备索引
有问题欢迎留言交流~
cuda安装教程:https://www.csdn.net/tags/Mtjacg5sOTA5NTctYmxvZwO0O0OO0O0O.html
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/152757.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有