Tricks for NVidia and CUDA on Debian
Moved some NVidia and CUDA tricks here, to keep the install instructions to basics.
You need to install the drivers first. See NVidia Driver and CUDA on Debian.
Coding with CUDA # ↑
You just installed CUDA. 'sudo apt-get install cuda-toolkit'. If you actually want to code with it, you might need additional packages.
$
Test CUDA with hashcat # ↑
You can test CUDA with hashcat. Crack some password with hashcat. Without CUDA, hashcat says "CUDA SDK Toolkit not installed or incorrectly installed.". With CUDA, hashcat says "CUDA API (CUDA 13.0)".
Sources.list for Debian 13-trixie # ↑
You are going to need non-free and contrib in sources.list. Edit it 'sudoedit /etc/apt/sources.list', then 'sudo apt-get update'.
/etc/apt/sources.list
deb https://deb.debian.org/debian trixie main contrib non-free-firmware non-free
deb-src https://deb.debian.org/debian trixie main contrib non-free-firmware non-free
deb https://deb.debian.org/debian trixie-updates main contrib non-free-firmware non-free
deb-src https://deb.debian.org/debian trixie-updates main contrib non-free-firmware non-free
deb https://deb.debian.org/debian trixie-backports main contrib non-free-firmware non-free
deb-src https://deb.debian.org/debian trixie-backports main contrib non-free-firmware non-free
deb https://security.debian.org/debian-security trixie-security main contrib non-free-firmware non-free
deb-src https://security.debian.org/debian-security trixie-security main contrib non-free-firmware non-free
Once you have updated your sources.list and ran 'sudo apt-get update', you can install NVidia drivers.
Install NVidia Driver and CUDA on Debian.
Fix: Kernel update kills nvidia-driver # ↑
This is just background information. It will work by following install instructions.
Many tutorials incorrectly advise you to install specific version of kernel headers. That does not work: when kernel binary (linux-image*) updates, your kernel headers (linux-headers*) are left too old. Thus, dkms cannot compile the latest NVidia driver. And you don't get grahical desktop. For example, it's not recommended to install only "linux-headers-$(uname -r)", because that expands to linux-headers-6.12.113+deb13-amd64. A bit too specific!
Just like shown above, you need to install the metapackage that always installs the latest kernel headers. You likely have linux-image-amd64 (metapackage), so you need to 'sudo apt-get install linux-headers-amd64'. You can see this yourself with 'dpkg --list 'linux-image*'|grep ^ii|grep meta'.
NVidia PGP keys # ↑
How can you verify NVidia PGP key? No idea, there seems to be many.
Different key is installed by different versions of the package with the same name (including the version number) cuda-keyring_1.1-1_all.deb. This package installs both sources.list entry and the trusted key.
$ pub rsa4096 2022-04-14 [SC]
EB69 3B30 35CD 5710 E231 E123 A4B4 6996 3BF8 63CC
$ pub rsa4096 2025-08-15 [SCEA]
0218 2E60 104F CDC2 6EAE 1B85 97A5 D4CB 8793 F200
uid Kitmaker (Debian 13 Trixie) <kitmaker@nvidia.com>
Sources # ↑
NVidia 2025: CUDA Installation Guide for Linux
NVidia 2025: NVIDIA Driver Installation Guide
Debian Wiki: Nvidia Proprietary GPU Drivers