安装pytorch (RTX2080 Ti+cuda10.1+cudnn7.5.0)

1、linux修改源镜像地址
修改镜像文件:

https://blog.csdn.net/maizousidemao/article/details/79127695

  1. cp /etc/apt/source.list /etc/apt/source.list.backup

  2. sudo gedit sources.list

打开
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
选择合适的系统复制文本至 /etc/apt/sources.list

3.sudo apt update

另一种编辑文件方式:
vim /etc/apt/sources.list
在正常模式下:“dd” 删除光标所在的行
按“i”/”Insert”键进行输入,编辑完全后按“Esc”,shift+;, 文本左下方则出现“:”,键入wq,按回车则保存修改退出了。

安装深度学习框架超齐全博客:
https://blog.csdn.net/wuzhiwuweisun/article/details/82753403

2.安装cuda 10.1

解决正常安装cuda10.1后,但nvcc -V无法显示cuda版本号的问题:
https://blog.csdn.net/weixin_42106049/article/details/85065489
添加环境变量 gedit ~/.bashrc
在末尾添加环境变量,并保存
export PATH= P A T H : / u s r / l o c a l / c u d a / b i n e x p o r t L D L I B R A R Y P A T H = / u s r / l o c a l / c u d a − 10.1 / b i n : PATH:/usr/local/cuda/bin export LD_LIBRARY_PATH=/usr/local/cuda-10.1/bin: PATH:/usr/local/cuda/binexportLDLIBRARYPATH=/usr/local/cuda10.1/bin:LD_LIBRARY_PATH
输入nvcc -V则会正常显示cuda 版本(若无,重启即可)
1

3、安装cudnn
sudo tar -xzvf cudnn-10.1-linux-x64-v7.5.0.56.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*

查看 CUDNN 版本:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
安装pytorch (RTX2080 Ti+cuda10.1+cudnn7.5.0)_第1张图片

4、安装pytorch和torchvision
torch 是主模块, 用来搭建神经网络的, torchvision 是辅模块, 有数据库, 还有一些已经训练好的神经网络等着你直接用, 比如 (VGG, AlexNet, ResNet).

到官网上选择合适的版本,上面会自动给出下载安装命令。
https://pytorch.org/
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=debnetwork

学校网络维护的问题,网络特别不正常,最终采用的方法:(即离线安装pythorch

  1. 找人帮忙到官网下载了:
    pytorch-1.0.1-py3.6_cuda10.0.130_cudnn7.4.2_2.tar.bz2
  2. 路径换到压缩包所在位置,输入一下命令:
    conda install pytorch-1.0.1-py3.6_cuda10.0.130_cudnn7.4.2_2.tar.bz2
    conda install torchvision (切记不要pip install torchvision混用,不然会出现以下问题)

出现问题解决:
https://blog.csdn.net/dongfang1984/article/details/81363834

我的操作:
libcudnn.so.7 -> libcudnn.so.7.5.0

sudo ln -sf /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7.5.0 /usr/local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7

出现问题及解决方案:
libcudart.so.10.0:: cannot open shared object file: No such file or directory
sudo ln -s /usr/local/cuda-10.1/lib64/libcudart.so.10.1 /usr/lib
sudo ln -s /usr/local/cuda-10.1/lib64/libcudart.so.10.1 /usr/lib/libcudart.so.10.0
sudo ldconfig

libcusparse.so.10.0: cannot open shared object file: No such file or directory
sudo ln -s /usr/local/cuda-10.1/lib64/libcusparse.so /usr/lib
sudo ln -s /usr/local/cuda-10.1/lib64/libcusparse.so /usr/lib/libcusparse.so.10.0
sudo ldconfig

检测是否安装成功:
进入python
import torch
正常import即可。
或者 conda list 查看安装库里有没有pytorch和torchvision

学习pytorch的博客和网站:

https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py

https://morvanzhou.github.io/tutorials/machine-learning/torch/

修改pip源的博客推荐:
https://blog.csdn.net/action1024/article/details/81295442

你可能感兴趣的:(Installation,for,deep,learning)