18.04 版每次升级内核后,nvidia 模块都会丢失

18.04 版每次升级内核后,nvidia 模块都会丢失

每次内核升级后,当我重新启动时,我只会看到一个空白屏幕

看起来专有的 nvidia 内核模块没有自动重新编译

我必须启动恢复模式并执行

dpkg-reconfigure nvidia-dkms-415

此后一切都顺利,直到下一次升级。

我猜系统中出了什么问题,最初我尝试安装来自 nvidia 的 nvidia 驱动程序,但最终将其删除并只使用了 ubuntu 驱动程序。

有什么建议可以帮我整理系统吗?我不想重新安装。

sudo dkms 状态

Error! Could not locate dkms.conf file.  
File:  does not exist.

ls /var/lib/dkms

dkms_dbversion  nvidia

ls /var/lib/dkms/nvidia/

410.78  415.27  kernel-4.15.0-39-generic-x86_64  kernel-4.15.0-45-generic-x86_64

sudo ubuntu-drivers 设备

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==  
modalias : pci:v000010DEd00001B81sv00001028sd00003301bc03sc00i00  
vendor   : NVIDIA Corporation  
model    : GP104 [GeForce GTX 1070]  
driver   : nvidia-driver-390 - third-party free  
driver   : nvidia-driver-415 - third-party free recommended  
driver   : nvidia-driver-396 - third-party free  
driver   : nvidia-driver-410 - third-party free  
driver   : xserver-xorg-video-nouveau - distro free builtin

我正在使用这个苯甲酸

deb-src http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic main  

sudo apt purge 'nvidia.*'
sudo apt install nvidia-driver-415

output:   
...
Setting up nvidia-dkms-415 (415.27-0ubuntu0~gpu18.04.2) ...
update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
Loading new nvidia-415.27 DKMS files...
Building for 4.15.0-45-generic
Building for architecture x86_64
Building initial module for 4.15.0-45-generic
Secure Boot not enabled on this system.
Done.

nvidia:
Running module version sanity check.

Good news! Module version 415.27 for nvidia.ko
exactly matches what is already found in kernel 4.15.0-45-generic.
DKMS will not replace this module.
You may override by specifying --force.

nvidia-modeset.ko:
Running module version sanity check.

Good news! Module version 415.27 for nvidia-modeset.ko
exactly matches what is already found in kernel 4.15.0-45-generic.
DKMS will not replace this module.
You may override by specifying --force.

nvidia-drm.ko:
Running module version sanity check.

Good news! Module version 415.27 for nvidia-drm.ko
exactly matches what is already found in kernel 4.15.0-45-generic.
DKMS will not replace this module.
You may override by specifying --force.

nvidia-uvm.ko:
Running module version sanity check.

Good news! Module version  for nvidia-uvm.ko
exactly matches what is already found in kernel 4.15.0-45-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod...

DKMS: install completed.
Setting up nvidia-driver-415 (415.27-0ubuntu0~gpu18.04.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for initramfs-tools (0.130ubuntu3.6) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-45-generic

现在:

dkms 状态

nvidia, 415.27, 4.15.0-45-generic, x86_64: installed

答案1

你的dkms坏了。我建议这样修复:

sudo rm -r /var/lib/dkms/nvidia
sudo apt install --reinstall dkms
sudo apt purge 'nvidia.*'
sudo apt install nvidia-driver-415

这将清理 dkms 目录,dkms.conf正确创建并安装驱动程序。

答案2

我想您可能会发现这里的解决方案与 Nvidia 驱动程序、内核版本或 DKMS 没有直接关系。

这里的问题是您的系统默认的 GCC 和 G++ 版本。

在我的系统上,GCC 设置为旧版本 7.4,我将编译器版本升级到 8.0,G++ 也升级到版本 8。

然后我将 GCC 8 设置为默认编译器,这终于解决了问题。最新的主流内核安装顺利,Nvidia 模块(x4 .ko 文件)也顺利编译。系统再次运行良好。

相关内容