Ubuntu18.04系统配置cuda10.1、cudnn、pytorch

Ubuntu18.04系统配置cuda10.1、cudnn、pytorch

  • cuda配置

桌面版18.04.2服务器版18.04.5

cuda配置

下载deb cuda+显卡驱动(官网地址)

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda //-y会默认yes

配置环境变量

echo 'export PATH=/usr/local/cuda-10.1/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

之后重启
cuda样例代码测试


cd /usr/local/cuda-10.1/samples/1_Utilities/deviceQuery
sudo make
sudo ./deviceQuery

cudnn安装

(注册登陆才能下载)
(官网地址)
Ubuntu18.04系统配置cuda10.1、cudnn、pytorch_第1张图片
下载cuDNN Library for Linux

在安装包所在路径下解压:

tar -xzvf cudnn-10.1-linux-x64-v7.6.1.34.tgz

将解压所得文件copy到CUDA的系统路径下(注意实际安装的CUDA版本和路径),并给予权限:

sudo cp cuda/include/cudnn.h /usr/local/cuda-10.1/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.1/lib64
sudo chmod a+r /usr/local/cuda-10.1/include/cudnn.h /usr/local/cuda-10.1/lib64/libcudnn*

cudnn测试

下载cudnn Code Samples…文件:
解压:libcudnn7-doc_7.6.1.34-1+cuda10.1_amd64.deb这个文件
找到mnistCUDNN这个文件夹然后编译执行:

make make
./mnistCUDNN

pytorch下载
(官网地址)
Ubuntu18.04系统配置cuda10.1、cudnn、pytorch_第2张图片
在官网选择自己适合的下载即可

你可能感兴趣的:(pytorch)