Nvidia drivers on Debian 13

Have you just installed Debian 13 on your PC and want to use your new Nvidia graphics card? Here’s a quick guide I put together using information I gathered from all over the internet to make sure it works the first time and, most importantly, with every new kernel release!

Installation

If you haven’t already done so, lets expand the list of package sources to include “non-free” since we want to use the official Nvidia drivers:

sudo sed -i 's/main/main non-free contrib/g' /etc/apt/sources.list

Then we use a classic “couple update upgrade” to make sure our system is up to date:

sudo apt update && sudo apt upgrade

Now we’re ready to install what we need to get the NVIDIA drivers and everything else required for them to work with our system:

sudo apt install linux-headers-$(uname -r) build-essential dkms nvidia-detect nvidia-driver nvidia-kernel-dkms

After a full system restart, you should be able to find the NVIDIA Settings app on your system and enjoy the satisfaction of knowing that everything is working properly:

After a kernel update

Every time your kernel is updated, you’ll need to reinstall the associated headers so that the drivers are reinstalled. This process isn’t automatic, and if you don’t do it, you won’t be able to boot your system, except in safe mode, to try to troubleshoot it using the commands below.

So, while you’re at it, as soon as you update your system and see a dependency in the package list whose name starts with “linux-image-”, run this command to install the headers and reinstall the drivers:

linux-image-6.12.95+deb13-amd64 will be installed

So I run the following command, using the dependency’s version number to install the correct associated headers:

sudo apt install linux-headers-6.12.95+deb13-amd64
NVIDIA drivers are properly updated and installed to work with the new kernel