Nvidia Driver Installation on Ubuntu
October 3, 2025
Ubuntu
Nvidia Driver Installation
- Check if the driver is already installed by running
nvidia-smi. To remove the driver, runsudo apt purge nvidia*followed bysudo apt autoremove. - First, run
sudo apt update. - Install the correct Linux headers
sudo apt install linux-headers-$(uname -r). - Install ubuntu-drivers
sudo apt install ubuntu-drivers-common. - Install the recommended driver from
ubuntu-drivers devices, e.g.sudo apt install nvidia-driver-550. - Remember to reboot the system.
Troubleshooting
If running nvidia-smi gives 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.
- Check the version of the driver
ls /usr/src | grep nvidia. This will give you the version of the driver, e.g.nvidia-535.309.01. - Install the
dkmspackagesudo apt-get install dkms. - Install the correct correct version with
dkms:sudo dkms install -m nvidia -v 535.309.01.
If error still occurs, e.g.
Error! Your kernel headers for kernel 6.8.0-117-generic cannot be found at /lib/modules/6.8.0-117-generic/build or /lib/modules/6.8.0-117-generic/source.
Please install the linux-headers-6.8.0-117-generic package or use the --kernelsourcedir option to tell DKMS where it's located.
Just install the kernel header: sudo apt install linux-headers-6.8.0-117-generic.