pytorch安装 |
您所在的位置:网站首页 › mirror资源下载 › pytorch安装 |
在安装好cuda和cudnn之后安装pytorch的方法
cudnn安装: 到cudnn官网下载:cudnn官方 下载cuDNN Library for Linux (x86_64)解压缩: 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 安装pytorch: 网上很多的方法都不是镜像下载,或者镜像下载因为系统的问题找不到库打开官网,找到对应合适的版本(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 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |