Ubuntu18.04安装N卡驱动、CUDA10.0、cuDNN7.5.0
N卡驱动
先添加源:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
然后执行:
ubuntu-drivers devices
查看合适的显卡驱动,显示如下:
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001F11sv00001462sd0000126Abc03sc00i00
vendor : NVIDIA Corporation
driver : nvidia-driver-418 - third-party free
driver : nvidia-driver-430 - third-party free recommended
driver : xserver-xorg-video-nouveau - distro free builtin
这里虽然推荐安装nvidia-driver-430
,但是亲测重启后无法进入图形界面,因此选择安装nvidia-driver-418
:
sudo apt install nvidia-driver-418
安装并重启后,可以打开N卡设置界面,确认驱动安装成功:
nvidia-settings
CUDA 10.0
先从官网上下载安装程序,本人选择的是:
按照官网给的教程:
sudo sh cuda_10.0.130_410.48_linux.run
在安装的时候,记得看清选项,不用再安装显卡驱动了
安装完后:
sudo gedit ~/.bashrc
在文件最后加上:
export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64”
export CUDA_HOME=/usr/local/cuda
export PATH="$CUDA_HOME/bin:$PATH"
保存修改,并更新配置文件:
source ~/.bashrc
打开新终端,检查Cuda是否安装成功:
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
cuDNN 7.5.0
先从官网上下载,本人选择的是:
- 假设下载完后解压缩至
/home/admin/Downloads/CUDA
,那么在/home/admin/Downloads/CUDA/cudnn-10.0-linux-x64-v7.5.0.56/cuda/
下有include
和lib64
两个文件夹- Cuda默认安装位置
/usr/local/cuda-10.0
sudo cp -r /home/admin/Downloads/CUDA/cudnn-10.0-linux-x64-v7.5.0.56/cuda/* /usr/local/cuda-10.0/
检查cuDNN是否安装成功
输入如下命令:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2