DEV Community

Dmitry Gordin
Dmitry Gordin

Posted on

1

NVIDIA Drivers with Secure Boot on Ubuntu

After enabling Secure Boot in BIOS settings on my PC with Kubuntu, I noticed laggy animations. When checking nvidia-smi, I got this error:

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

Updating apt packages and drivers didn't help. After a day of troubleshooting, here's what worked for me:

# Install necessary tools
sudo apt update && sudo apt install -y openssl mokutil

# Create directory for keys
sudo mkdir -p /var/lib/shim-signed/mok/

# Generate the key that will be used to sign drivers
sudo openssl req -new -x509 -newkey rsa:2048 -keyout /var/lib/shim-signed/mok/MOK.priv -outform DER -out /var/lib/shim-signed/mok/MOK.der -days 36500 -subj "/CN=MyKey4Nvidia/" -nodes

# Import generated key
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
Enter fullscreen mode Exit fullscreen mode

Now you will be prompted to enter a new password, this can be any string (not necessary your user's password). Remember it! You'll need to enter it after reboot.

# Reinstall NVIDIA drivers
sudo apt purge 'nvidia*'
sudo apt autoremove
sudo ubuntu-drivers autoinstall
Enter fullscreen mode Exit fullscreen mode

Reboot your system. At the beginning of the boot process, you'll see a countdown for 10 seconds to enter the MOK management menu.
Select "Enroll MOK", press continue, and enter the password you created earlier. After enrollment, select the reboot option.

That's it! After booting up, you should have working NVIDIA drivers. Verify this with the nvidia-smi command.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay