linux上cuda与cudnn环境搭建

本文介绍在linux上如何安装cuda及cudnn

cuda官网:https://developer.nvidia.com/cuda-downloads

cuda下载

下载cuda

cuda安装

1
2
3
4
5
6
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.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get updatesudo apt-get -y install cuda

cudnn官网:https://developer.nvidia.com/rdp/cudnn-download

cudnn安装

1
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb

测试

重启系统,然后运行下面例子

1
2
3
4
5
6
7
8
#查找测试例子所在位置
locate cuda | grep 'samples'

#编译测试例子
sudo make -j8

#运行测试例子
./deviceQuery

测试成功提示

输出提示PASS,则安装成功!!!