Installing and Troubleshooting NVIDIA Drivers on Ubuntu
This guide walks a new user through safely installing NVIDIA proprietary drivers on Ubuntu (24.04 and similar). Follow the numbered steps exactly. If Secure Boot prompts appear, follow the enrollment steps described below.
1 Detect NVIDIA hardware
Section titled “1 Detect NVIDIA hardware”Identify PCI devices and driver info:
lspci -nnk | grep -iA3 \[03\]:# or more specificallylspci -nnk | grep -iA3 nvidia# show kernel modules and driverslspci -vnn | grep -i nvidia -A 12If output shows an NVIDIA VGA/3D controller, proceed.
2 Recommended automatic install (safe)
Section titled “2 Recommended automatic install (safe)”Ubuntu provides ubuntu-drivers to recommend tested packages. Run:
sudo ubuntu-drivers devicessudo ubuntu-drivers autoinstallsudo rebootThis installs a distribution-tested driver and DKMS modules if needed. Reboot to load the new kernel module.
3 Manual install of a specific driver version
Section titled “3 Manual install of a specific driver version”To explicitly install a version (example nvidia-driver-535):
sudo apt updatesudo apt install -y nvidia-driver-535 nvidia-utils-535sudo rebootVerify installation after reboot:
nvidia-smilsmod | grep nvidia4 Secure Boot and MOK enrollment
Section titled “4 Secure Boot and MOK enrollment”If Secure Boot is enabled, the kernel will refuse unsigned modules. When installing DKMS-based drivers, Ubuntu often triggers a MOK enrollment prompt on next reboot. If you miss it, enroll manually:
Generate a key (run once):
sudo apt install -y mokutil opensslsudo openssl req -new -x509 -newkey rsa:2048 -keyout /root/MOK.priv -out /root/MOK.pem -nodes -days 3650 -subj "/CN=Custom MOK/"sudo mokutil --import /root/MOK.pemYou will be asked to set a password. Reboot, enter the MOK manager, select “Enroll MOK”, and provide the password to complete enrollment.
Alternatively, disable Secure Boot in firmware settings (less recommended for security-aware users).
5 Troubleshooting
Section titled “5 Troubleshooting”If nvidia-smi fails or shows no devices:
- Check kernel messages:
dmesg | grep -i nvidiaandjournalctl -k | tail. - Check DKMS build logs in
/var/lib/dkms/<module>/<version>/build/make.log. - Confirm nouveau is not blocking:
lsmod | grep nouveau. If present, create/etc/modprobe.d/blacklist-nouveau.confwithblacklist nouveauandoptions nouveau modeset=0, then runsudo update-initramfs -uand reboot. - Check
lspci -kto see which kernel driver is in use for the VGA device. - If module signing errors appear, review Secure Boot MOK enrollment or sign the module manually (see Secure Boot guide).
- If X/Wayland fails, check
/var/log/Xorg.0.logandjournalctl -bfor compositor messages.
6 Post-install checks
Section titled “6 Post-install checks”nvidia-smishows GPU status and driver version.glxinfo | grep OpenGLorvulkaninfo(if using Vulkan) to verify rendering.
This guide focuses on Ubuntu’s packaged drivers. If you need instructions for installing NVIDIA’s runfile installer, request that explicitly — it requires extra care (kernel headers, stopping display manager, and manual DKMS integration).