Score:1

Cannot load NVIDIA driver (Ubuntu)

ng flag

I am having issues loading the NVIDIA driver on Ubuntu 21.04. The result of nvidia-smi is

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. 
Make sure that the latest NVIDIA driver is installed and running.

And the result of nvidia-settings:

ERROR: NVIDIA driver is not loaded
ERROR: Unable to load info from any available system

I have tried reinstalling the latest NVIDIA driver available, 470.57.02 (my current kernel is 5.14.2-051402-generic). When installing with sudo apt-get update and sudo apt-get install nvidia-driver-470 I get this error:

    INFO:Enable nvidia
    DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
    DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
    DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
    Loading new nvidia-470.57.02 DKMS files...
    Building for 5.14.2-051402-generic 5.14.3-051403-generic
    Building for architecture x86_64
    Building initial module for 5.14.2-051402-generic
    ERROR (dkms apport): kernel package linux-headers-5.14.2-051402-generic is not supported
    Error! Bad return status for module build on kernel: 5.14.2-051402-generic (x86_64)
    Consult /var/lib/dkms/nvidia/470.57.02/build/make.log for more information.
    dpkg: error processing package nvidia-dkms-470 (--configure):
     installed nvidia-dkms-470 package post-installation script subprocess returned error exit status 10
    dpkg: dependency problems prevent configuration of nvidia-driver-470:
     nvidia-driver-470 depends on nvidia-dkms-470 (= 470.57.02-0ubuntu1); however:
      Package nvidia-dkms-470 is not configured yet.
    
    dpkg: error processing package nvidia-driver-470 (--configure):
     dependency problems - leaving unconfigured
    Setting up libnvidia-encode-470:amd64 (470.57.02-0ubuntu1) ...
    No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                              Processing triggers for desktop-file-utils (0.26-1ubuntu1) ...
    Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
    Processing triggers for libc-bin (2.33-0ubuntu5) ...
    Processing triggers for man-db (2.9.4-2) ...
    Processing triggers for mailcap (3.68ubuntu1) ...
    Processing triggers for initramfs-tools (0.139ubuntu3) ...
    update-initramfs: Generating /boot/initrd.img-5.14.3-051403-generic
    Errors were encountered while processing:
     nvidia-dkms-470
     nvidia-driver-470
    E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried purging all NVIDIA packages with sudo apt-get purge nvidia-*, sudo apt-get autoremove and repeating the process, but no success. I also tried installing it on a previous kernel (5.11), installing a previous driver (nvidia-driver-460), but nothing worked.

The card is correctly detected. This is the output of lspci | grep NVIDIA:

01:00.0 VGA compatible controller: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q] (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 228e (rev a1)

I also have tried the solutions from Unable to install nvidia drivers - unable to locate package, and NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running, still no success.

Any advice? Thanks!

Nmath avatar
ng flag
`kernel package linux-headers-5.14.2-051402-generic is not supported` - This seems to be the problem. Also running `sudo apt-get update && sudo apt-get...` is not very helpful when you are problem solving since you won't get a complete output. (You also did not provide the complete output in your question.) Are your other packages up-to-date? Why/how are you using 5.14?
elperno avatar
ng flag
My laptop is a msi gs66, I had several issues with the wireless adapter and had to upgrade to the latest kernel and firmware to be able to detect it. With this kernel the wireless adapter works fine. I am running `update` and `upgrade` independently, just wrote it like this to summarize, but I'll edit the post. Apologies. The rest of the packages are up-to-date.
elperno avatar
ng flag
But to clarify: As described in the question, I'm having this problem on *both kernels*, `5.14` and on `5.11`. In `5.11` the driver seems to install fine, but after rebooting I get the same errors on `nvidia-smi` and `nvidia-settings`.
elperno avatar
ng flag
I recently installed **Ubuntu 20.04** in a new disk partition, and I still obtain the same result. Is it possible that this is happening because of a GPU hardware failure?
Score:2
ng flag

I finally succeeded in fixing it. The problem was indeed related to Secure Boot. I already had it disabled, but along the way I had set the boot mode as UEFI with CSM instead of plain UEFI. That was causing trouble.

(The answer by w-sky at NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running gave me the hint)

So these are the steps that fixed my problem:

  • In Additional drivers, deactivate the NVIDIA driver by choosing x.org (nouveau) instead. Reboot.
  • Boot menu, select UEFI (not UEFI with CSM!!) and disable Secure Boot.
  • In Additional drivers, activate again NVIDIA driver and reboot again.

You can probably leave Secure Boot enabled. In that case, when setting the NVIDIA driver you'll be requested to enroll a new MOK key, and after rebooting you'll be asked to type it in again in order to grant hardware access to the driver. I did not do it in my case, as enabling Secure Boot also prevented iwlwifi drivers to access the AX210 wifi card in my laptop.

Good luck!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.