Cannot load NVIDIA driver (Ubuntu)

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!