What's the process for fixing NVIDIA drivers after kernel updates in Ubuntu 20.04

Hello all,

So it seems like every time there’s a kernel update in Ubuntu 20.04, I can no longer boot to the desktop due to NVIDIA drivers. I’m just curious if someone can point me in the right direction or possibly explain what the process to fix this is for the next update? I’ve been doing some digging and it seems like booting into console mode, purging the nvidia drivers and then using ubuntu-drivers autoinstall command should work, but I’m curious if this is the correct method, or if this should be happening at all? I’m running Ubuntu 20.04 LTS on a laptop with a NVIDIA GTX 1650 Max-Q.

It shouldn’t happen, dkms should take care of it. You can use
dkms status
to check if the driver is correctly added for your kernel.

Hello @generix. You might remember me from a previous thread you were helping me with last month. I just re-installed Ubuntu 20.04 this morning and chose the 510 drivers during the installation. Everything went smoothly and I’m currently using the NVIDIA 510 drivers with the 5.13.35-generic kernel. My question is this, how can I install the dkms drivers from this state? I made a post on askubuntu listing things I tried that failed before having to re install this morning (see below):

I currently have 5.13.35-generic kernel on hold so my install won’t be broken by a future update, but I’m not sure what the process is to install the dkms drivers. DKMS is not installed at all on my system at the moment, but I’d like to replace the 510 non-dkms drivers with the 510 dkms drivers. Thanks again for your help!

DKMS should be installed automatically once you install the nvidia driver using Software&Updates or using apt. Installing the non-dkms driver version requires manual intervention. Please post the output of
dkms status
Otherwise, it might be that the nvidia driver is installed but not added to the initrd:
https://forums.developer.nvidia.com/t/linux-mint-nvidia-driver-loads-with-startx-but-not-on-initial-startup/168262/2

@generix That’s so strange, I mentioned that I installed the 510 drivers during the Ubuntu installation with the option to install proprietary drivers but my output of dkms status is:

mauro@prestige:~$ dkms status

Command ‘dkms’ not found, but can be installed with:

sudo apt install dkms

I installed DKMS and it there’s no output at all if I run dkms status command. These are all the NVIDIA packages I have installed:

mauro@prestige:~$ dpkg --list | grep nvidia
ii  libnvidia-cfg1-510:amd64                   510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-common-510                       510.47.03-0ubuntu0.20.04.1          all          Shared files used by the NVIDIA libraries
ii  libnvidia-compute-510:amd64                510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA libcompute package
ii  libnvidia-compute-510:i386                 510.47.03-0ubuntu0.20.04.1          i386         NVIDIA libcompute package
ii  libnvidia-decode-510:amd64                 510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA Video Decoding runtime libraries
ii  libnvidia-decode-510:i386                  510.47.03-0ubuntu0.20.04.1          i386         NVIDIA Video Decoding runtime libraries
ii  libnvidia-encode-510:amd64                 510.47.03-0ubuntu0.20.04.1          amd64        NVENC Video Encoding runtime library
ii  libnvidia-encode-510:i386                  510.47.03-0ubuntu0.20.04.1          i386         NVENC Video Encoding runtime library
ii  libnvidia-extra-510:amd64                  510.47.03-0ubuntu0.20.04.1          amd64        Extra libraries for the NVIDIA driver
ii  libnvidia-fbc1-510:amd64                   510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-fbc1-510:i386                    510.47.03-0ubuntu0.20.04.1          i386         NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-gl-510:amd64                     510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  libnvidia-gl-510:i386                      510.47.03-0ubuntu0.20.04.1          i386         NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  linux-modules-nvidia-510-5.13.0-30-generic 5.13.0-30.33~20.04.1                amd64        Linux kernel nvidia modules for version 5.13.0-30
hi  linux-modules-nvidia-510-5.13.0-35-generic 5.13.0-35.40~20.04.1                amd64        Linux kernel nvidia modules for version 5.13.0-35
ii  linux-modules-nvidia-510-generic-hwe-20.04 5.13.0-35.40~20.04.1                amd64        Extra drivers for nvidia-510 for the generic-hwe-20.04 flavour
ii  linux-objects-nvidia-510-5.13.0-30-generic 5.13.0-30.33~20.04.1                amd64        Linux kernel nvidia modules for version 5.13.0-30 (objects)
hi  linux-objects-nvidia-510-5.13.0-35-generic 5.13.0-35.40~20.04.1                amd64        Linux kernel nvidia modules for version 5.13.0-35 (objects)
ii  linux-signatures-nvidia-5.13.0-30-generic  5.13.0-30.33~20.04.1                amd64        Linux kernel signatures for nvidia modules for version 5.13.0-30-generic
hi  linux-signatures-nvidia-5.13.0-35-generic  5.13.0-35.40~20.04.1                amd64        Linux kernel signatures for nvidia modules for version 5.13.0-35-generic
ii  nvidia-compute-utils-510                   510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA compute utilities
ii  nvidia-driver-510                          510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA driver metapackage
ii  nvidia-kernel-common-510                   510.47.03-0ubuntu0.20.04.1          amd64        Shared files used with the kernel module
ii  nvidia-kernel-source-510                   510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA kernel source package
ii  nvidia-prime                               0.8.16~0.20.04.1                    all          Tools to enable NVIDIA's Prime
ii  nvidia-settings                            470.57.01-0ubuntu0.20.04.3          amd64        Tool for configuring the NVIDIA graphics driver
ii  nvidia-utils-510                           510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA driver support binaries
ii  screen-resolution-extra                    0.18build1                          all          Extension for the nvidia-settings control panel
ii  xserver-xorg-video-nvidia-510              510.47.03-0ubuntu0.20.04.1          amd64        NVIDIA binary Xorg driver

Odd. Does the -dkms driver package appear if you now use Software&Updates to reinstall the driver?

@generix Nope, all the listed drivers are non-dkms. I did used the “minimal install” option on Ubuntu, maybe that had something to do with it?

It shouldn’t since dkms gets pulled in by installing the nvidia drivers for the first time. At least it should, I don’t know why this isn’t the case with your install. Maybe just the 510 driver package is broken, did you also try to install driver v470?

@generix Nope, I need this laptop for school and I’ve re-installed Ubuntu twice in the last week due to kernel updates breaking my NVIDIA drivers and not knowing how to fix this. I’m going to have to hold off on updates and either figure this out when I have time, or, unfortuntely, go back to Windows as much as I don’t want to. I just did an apt upgrade and there’s already a 37-generic kernel ready to be installed, I guess i’ll just have to ignore it for now.

I re-checked ubuntu packaging and seems I missed that tey now switched to using pre-compiled, signed modules instead of dkms when using the third party software option or drivers autoinstall. So the modules are now in the packages

linux-modules-nvidia-510-5.13.0-35-generic
linux-objects-nvidia-510-5.13.0-35-generic

for the respective kernels.

@generix Interesting, I’ll have to look into this when I have the time. For now, I’m holding off on updates. I appreciate your help and knowledge, seriously, you’ve been a great help!

@generix Well, I got it to work by doing a “dist-upgrade” over just an apt upgrade.

I was having a similar issue on my debian machine. Whenever the kernel is updated, the nvidia driver fails to load. I created a script that automates the process of downloading the latest driver and installing it afterwards. You can find it here: GitHub - BdN3504/nvidia-driver-update