ubuntu显卡驱动安装(更新)-CUDA安装-cuDNN安装
文中参考了多篇文章,链接已放入文中,可自行点击参看
显卡驱动
CUDA安装和cuDNN安装
第一步,安装cuda,
到
安装完成后再~/.bashrc
文件中添加如下环境变量:
export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
验证是否安装成功,输入nvcc -V
指令,得到以下输出表示安装成功
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
第二步,安装cuDNN
到
输入安装指令:sudo dpkg -i cudnn-local-repo-ubuntu2004-8.4.0.27_1.0-1_amd64.deb
显卡驱动安装(或更新)
查看信息(
-
查看显卡型号:
ubuntu-drivers devices
-
验证是否禁用nouveau:
lsmod | grep nouveau
-
若有输出,证明没有禁用,进行:
sudo gedit /etc/modprobe.d/blacklist.conf
在文件末尾添加:
blacklist nouveau
options nouveau modeset=0
-
应用更改:
sudo update-initramfs -u
-
重启系统,然后执行(没有输出则禁用成功):
lsmod | grep nouveau
-
在实际操作过程中作者在输入第五条命令的时候有输出,但将其忽略也能成功安装。重新启动系统后关闭图形界面:
sudo service lightdm stop
-
如果提示unit lightdm.service not loaded,则先安装(界面选择)LightDm:
sudo apt install lightdm
-
跳出下一个界面后选择lightdm,再:
sudo service lightdm stop
-
更改安装包权限:
sudo chmod a+x NVIDIA****.run
(根据具体文件名填写)
-
开始安装:
sudo ./NVIDIA****.run -no-opengl-files
-
启动图像界面:
sudo service lightdm start
-
重启:
sudo reboot
-
测试是否成功:
nvidia-smi
驱动安装过程的界面中
The distribution-provided pre-install script failed! Are you sure you want to continue?
选择 yes 继续。
Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later?
选择 No 继续。
Nvidia’s 32-bit compatibility libraries?
选择 No 继续。
Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up.