Skip to content

Fixing nvidia gpu module on Ubuntu 20.04

Yanrui Ma edited this page Aug 20, 2020 · 4 revisions

[Update: I wouldn't have had to do all of the following had I chosen to download and upgrade graphics and third party software updates at the installation time]

I tumbled on the issue by accident. I tried to enable the gpu module on microk8s, but got an error saying the nvidia kernel module is not loaded. I opened "settings/about", sure enough, "graphics" says intel, which is the onboard unit, not nvidia. And "lsmod | grep nvidia" doesn't produce anything.

I ran this command

ubuntu-drivers devices

which outputs:

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001F91sv00001028sd00000905bc03sc02i00
vendor   : NVIDIA Corporation
model    : TU117M [GeForce GTX 1650 Mobile / Max-Q]
driver   : nvidia-driver-440-server - distro non-free
driver   : nvidia-driver-435 - distro non-free
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-440 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

From which we can see that the recommended driver version is 440.

So I ran dpkg --list | grep nvidia, and nvidia-driver-440, along with other nvidia 440 components, are among the list of installed packages.

So the driver is installed, but is it being used? Next I ran Ubuntu's "Software & Updates" gui application, under "Aditional Drivers", and the recommended version is not selected. So I selected the correct version, and reboot the box.

I was expecting the the problem to be fixed, but it still persists. Searching on google came up with a couple of links that turned out to be helpful. One suggests that the secure booting option somehow marks the nvidia drivers to be unsafe so refuses to load them, and another suggests to remove the blacklist for nvidia under /lib/modprobe.d .

So I tried the following:

  1. Reboot, turn off secure booting under bios, then reboot into ubuntu
  2. Check /lib/modeprobe.d and see the blacklist for nvidia file is there. Run prime-select nvidia, command succeeds, check /lib/modprobe.d directory, the blacklist is gone
  3. Reboot again

After that, "settings/about" shows graphics to be "GeForce GTX 1650/PCIe/SSE2 / GeForce GTX 1650/PCIe/SSE2", so success! And lsmod | grep nvidia gives:

nvidia_uvm            966656  0
nvidia_drm             45056  11
nvidia_modeset       1114112  8 nvidia_drm
nvidia              20680704  664 nvidia_uvm,nvidia_modeset
drm_kms_helper        184320  2 nvidia_drm,i915
ipmi_msghandler       106496  2 ipmi_devintf,nvidia
drm                   491520  15 drm_kms_helper,nvidia_drm,i915

And sure enough, microk8s enable gpu succeeds as well.

Testing with "System Profiler and Benchark" shows that the graphics performance more than doubled.