NVIDIA三件套安装问题汇总

运行sudo dpkg --list | grep mvidia*还有输出

英伟达的相关包还没删干净,对照输出的还剩的包,挨个删干净。

# 重复执行
sudo apt-get --purge remove xxx
# 最终确保运行以下命令确保无输出
sudo dpkg --list | grep mvidia*

运行lsmod | grep nouveau无输出,但还提示让禁用

理论上驱动会自行禁用nouveau开源驱动,但玄学问题,你懂的。

# 进行手动爆破
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
# 添加以下内容
blacklist nouveau options nouveau modeset=0
# 执行该命令实现更新
sudo update-initramfs -u
# 再次安装NVIDIA驱动即可,安装完成后立即重启

Ps:实现更新后再次安装驱动完成后可能会黑屏,稍等一下。再强制重启。

如果无法进入图形界面,Ctrl+Alt+F1切换到字符界面,Ctrl+Alt+F7切换到图形界面

提示缺少gcc g++ make等包

依次安装即可,常见于新系统。

建议安装完成后装一下build-essential依赖包sudo apt-get install build-essential

提示An NVIDIA kernel module 'nvidia-uvm' appears to already be loaded in your kernel.

一般是其他进程还在占用gpu,重启后重新装驱动尝试一下

提示An NVIDIA kernel module 'nvidia-drm' appears to already be loaded in your kernel

应当是在使用GPU 驱动X-Window 时同时安装CUDA 的驱动程式,要解决这个问题,比较简洁的方法便是停止使用GPU。

# 获取root权限
sudo -i
# 关闭所有占用gpu进程,停止载入gpu驱动
systemctl isolate multi-user.target
modprobe -r nvidia-drm
# 重新安装驱动即可

安装cudnn

# 安装deb
sudo dpkg -i libcudnn8_8.0.5.39-1+cuda11.0_amd64.deb
# 提示如下
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8 is not a symbolic link

# 修复方式
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
sudo ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8

提示确认 kernel-source和kernel-devel

# 完整报错
  ERROR: Unable to find the kernel source tree for the currently running kernel.  Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat  
  Linux systems, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed.  If you know the correct kernel source files are installed, you may specify the kernel source path    
  with the '--kernel-source-path' command line option. 

解决方案

  1. 缺少kernel,先看kernel版本

    uname -r 
    # 如:5.4.0-050400-generic 即 5.4
  2. 从ubuntu内核库下载kernel,链接

    # 对应好kernel版本,如5.4
    # https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4/
    # 对应好发行版本,如amd64,如图:

    image-20220924100038333

    # 下载以下几个deb,安装顺序也按这个顺序
    linux-headers-5.4.0-050400_5.4.0-050400.201911242031_all.deb
    linux-headers-5.4.0-050400-generic_5.4.0-050400.201911242031_amd64.deb
    linux-modules-5.4.0-050400-generic_5.4.0-050400.201911242031_amd64.deb
    linux-image-unsigned-5.4.0-050400-generic_5.4.0-050400.201911242031_amd64.deb
  3. 重启

参考链接:https://blog.csdn.net/chris_pei/article/details/79203033

最后修改:2022 年 09 月 24 日
如果觉得我的文章对你有用,请随意赞赏