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.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

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

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay