How to Fix NVIDIA Driver Issues on Ubuntu: NVIDIA-SMI has failed...

How to Fix NVIDIA Driver Issues on Ubuntu: NVIDIA-SMI has failed...

If you’ve just installed the NVIDIA proprietary drivers on Ubuntu and run into this dreaded message:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.        

…and nvidia-smi still doesn’t work — you’re not alone.

This often happens when Secure Boot is enabled, which blocks unsigned kernel modules like NVIDIA’s from loading.

Here’s how to fix it, the easy way.


Solution: Disable Secure Boot in BIOS (Recommended)

If you’re not restricted by company policy and can access BIOS settings, this is the simplest and most reliable way to get NVIDIA drivers working on Ubuntu.

Step-by-step:

Step 1: Restart your computer.

sudo reboot        

Step 2: Press F2, DEL, ESC, or F10 during startup to enter the BIOS/UEFI setup screen.

Step 3: Navigate to the Boot or Security tab.

Step 4: Find Secure Boot, and set it to “Disabled”.

Step 5: Save changes and exit (usually via Save & Exit option or F10). Then, your PC will reboot.

Step 6: Once back on Ubuntu, open a terminal and run:

sudo modprobe nvidia
nvidia-smi        

If everything is working, you’ll see the NVIDIA GPU status and driver version — you’re all set! 🎉


Can’t Disable Secure Boot? (Advanced Users)

If you’re on a corporate laptop or a school device, BIOS may be password-locked, and disabling Secure Boot might not be allowed.

In this case, the alternative is to sign the NVIDIA kernel modules manually and enroll your public key into the UEFI system. This is possible, but it is more complete, and you need to repeat the steps every time you update the kernel or the driver.

If you decide to go through this way, here is the step-by-step guide:


TL;DR (for the busy devs)

  1. Manually create a MOK (Machine Owner Key)
  2. Sign NVIDIA .ko kernel modules with it
  3. Import the key into MOK with mokutil
  4. Enroll it on reboot
  5. Done. NVIDIA works.


Step-by-Step Setup

Step 1: Create a Signing Key

mkdir -p ~/mok-keys
cd ~/mok-keys

openssl req -new -x509 -newkey rsa:2048 \
  -keyout MOK.priv -outform DER -out MOK.der \
  -nodes -days 36500 \
  -subj "/CN=NVIDIA Secure Boot Module Signing/"        

  • MOK.priv: private key (used to sign modules)
  • MOK.der: public key (used for enrollment)
  • Valid for 100 years (adjust -days if you like)

Step 2: Sign the NVIDIA Kernel Modules

First, locate them:

find /lib/modules/$(uname -r) -type f -name 'nvidia*.ko'        

Now sign the core ones:

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
~/mok-keys/MOK.priv ~/mok-keys/MOK.der \
/lib/modules/$(uname -r)/updates/dkms/nvidia.ko

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
~/mok-keys/MOK.priv ~/mok-keys/MOK.der \
/lib/modules/$(uname -r)/updates/dkms/nvidia-modeset.ko

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
~/mok-keys/MOK.priv ~/mok-keys/MOK.der \
/lib/modules/$(uname -r)/updates/dkms/nvidia-drm.ko

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
~/mok-keys/MOK.priv ~/mok-keys/MOK.der \
/lib/modules/$(uname -r)/updates/dkms/nvidia-uvm.ko        

Optional: sign others like nvidia-peermem.ko as needed.

Step 3: Register the Key with MOK

sudo mokutil --import ~/mok-keys/MOK.der        

You’ll be prompted to create a one-time password. This will be used to enroll the key at boot.

Step 4: Reboot & Enroll the Key

Reboot the system:

sudo reboot        

On reboot, you’ll see a blue MOK Manager screen:

  1. Choose Enroll MOK
  2. Continue
  3. Enter your password
  4. Reboot again

This allows the kernel to trust modules signed with your key.

Step 5: Profit

Once you’re back in:

lsmod | grep nvidia
nvidia-smi        

You should now see your NVIDIA driver loaded and functioning! 🎉


Why This Works

Secure Boot checks the signature of any kernel module before loading. NVIDIA drivers installed via DKMS are not signed by default, so the kernel blocks them. By signing them yourself with a trusted key, you satisfy Secure Boot without compromising security.


Tips

  • When the kernel is updated or the driver is recompiled, you’ll need to re-sign the modules.
  • You can write a small script to automate this if it happens often.
  • Never share your private key (MOK.priv). Keep it safe.


Related:


To view or add a comment, sign in

More articles by Erencan Bulut

Insights from the community

Others also viewed

Explore topics