Installing NVIDIA drivers on Debian is essential for users who need to harness the full power of their NVIDIA GPUs, whether for gaming, graphics rendering, or CUDA-based computational tasks. Proper installation of these drivers ensures optimal performance and stability of your system, making it crucial to choose the right installation method based on your specific requirements.
On Debian 12 or 11, NVIDIA drivers can be installed using two primary methods. The first method involves using Debian’s default repository, which provides a stable and straightforward installation suitable for most users. For those who require the latest features, updates, and CUDA support, the second method is to add NVIDIA’s CUDA APT repository mirror, which offers access to the latest driver builds. This guide will walk you through both installation methods, ensuring your NVIDIA drivers are set up according to your system’s needs.
Pre-Installation Steps Before Nvidia Drivers Installation
Update Debian System Packages Before Nvidia Drivers Installation
Before proceeding with the tutorial, ensuring your system is up-to-date with all existing packages is good.
sudo apt update
Proceed to upgrade any outdated packages using the following command.
sudo apt upgrade
Previous Nvidia Installations From Debian (Situational)
When Nvidia drivers over the standard packages, it can result in unexpected issues, especially if you install the Nvidia drivers from Debian’s repository, then import the Nvidia Cuda repository and try to re-install or upgrade directly over those packages. If you use one method, stick to it, and if you want to swap, ensure you remove the previous installation to avoid conflicts.
Below, I will briefly review some options for removing the previous Nvidia Drivers.
Example 1: Remove Previous Nvidia Drivers Installed via APT
First, use a blanket command to remove any traces of Nvidia installation on your system:
sudo apt autoremove nvidia* --purge
Example 2: Remove Previous Nvidia Drivers Installed via RUNFILE
The second method is for anyone who installed the Nvidia drivers using the “.run” file. To remove the runfile type of installation, use the following command:
sudo /usr/bin/nvidia-uninstall
Example 3: Remove Previous Nvidia Cuda Drivers Installed via RUNFILE
Lastly, remove the CUDA toolkit runfile installation using the following command.
sudo /usr/local/cuda-X.Y/bin/cuda-uninstall
These few methods may remove the Nvidia Drivers.
Enable Contrib and Non-Free Repositories
The first task is enabling the “contrib” and “non-free” repositories in your Debian repositories. The command changes from Debian 12 Bookworm onwards. Ensure you use the correct command matching your Debian distribution version.
First, make sure you have installed the following on your Debian system:
sudo apt install software-properties-common -y
Debian 12 Bookworm and onwards:
sudo add-apt-repository contrib non-free-firmware
Debian 11 Bullseye downwards:
sudo add-apt-repository contrib non-free
Once added, update your APT cache with the following command:
sudo apt update
Method 1: Install Nvidia Drivers via DEFAULT APT Repository
Install Linux Kernel Headers
Before installing any Nvidia drivers, you must install the proper kernel headers for the NVIDIA driver to build with. You can install either 64bit or 32bit, and you can find this out by running the lscpu command:
lscpu | grep CPU
Example output:
CPU op-mode(s): 32-bit, 64-bit
CPU(s): 2
On-line CPU(s) list: 0,1
CPU family: 23
CPU MHz: 3900.025
NUMA node0 CPU(s): 0,1
From the output, the system is 64bit, so you need to install the following headers:
sudo apt install linux-headers-amd64
32-bit Debian systems, use the following command instead:
Note: DO NOT USE THE BELOW COMMANDS IF YOU ARE ON A 64-BIT SYSTEM.
non-PAE kernel:
sudo apt install linux-headers-686
PAE kernel:
sudo apt install linux-headers-686-pae
Install Nvidia Drivers via Debian’s Default Repository
Next, you can install the “nvidia-detect,” which will automatically suggest the best package for your graphics card.
To do this, use the following command:
sudo apt install nvidia-detect
With Nvidia-detect installed, execute the command to identify your current Nvidia Graphics Card:
nvidia-detect
The output reveals that the example machine features a GeForce GTX 1650 card and recommends installing the nvidia-driver package. However, this remains a suggestion.
Next, install the recommended package:
sudo apt install nvidia-driver linux-image-amd64
You will see a note about the free Nouveau graphics driver conflicting with the installed new driver. As per the message, you need to reboot to correct this; for now, press the “ENTER KEY” to proceed.
Reboot and Confirm Installation
Once installed, reboot your system:
sudo reboot
Situational: Install Nvidia Legacy Drivers (For Older Cards)
If your Nvidia Graphics card is old from 400 Series downwards, you must install the legacy drivers. The process is the same, just with a new install command:
sudo apt install nvidia-legacy-390xx-driver firmware-misc-nonfree
Once complete, do not forget to reboot your system.
sudo reboot now
You can technically install the 340 series, but it no longer has support and contains several major security flaws. Although you might consider replacing 390xx with 340xx, Debian advises against it.
Method 2: Install Nvidia Drivers via PPA
The second method lets you install the latest drivers for your desktop or server from the Nvidia Cuda APT repository. I suggest you use these drivers because you’ll get updates immediately after their release. This approach benefits security and performance since Nvidia frequently releases updates. Now, you also have the option to install the open-source version.
Identify Your Nvidia Graphics Card on Debian
If you have an older NVIDIA Graphics card, identify it to ensure support. However, if you own a brand-new card, you can skip this part because your card undoubtedly has support.
Now, let’s identify your graphics card module:
lspci | grep -e VGA
Example output:
03:00.0 VGA compatible controller: NVIDIA Corporation TU117 [GeForce GTX 1650] (rev a1)
Import Nvidia GPG Key
First, check if you have already installed the following packages by using this command:
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https dkms curl -y
Next, import the GPG key, and ensure you match the import to your distribution version.
Note: Please comment or message me via the contact form if the GPG import fails. Debian can occasionally change its GPG keys. This is rare, but it does occur; if it does, I’ll update the command.
Debian 12 Bookworm Import GPG Key for Nvidia:
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
Debian 11 Bullseye Import GPG Key for Nvidia:
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
Import Nvidia APT Repository
Second, import the repository for your Debian system, and again, ensure you import the correct one to match your Debian distribution version.
Debian 12 Bookworm Import Nvidia CUDA APT Repository:
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
Debian 11 Bullseye Import Nvidia CUDA APT Repository:
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
Install Nvidia Drivers – Proprietary or Open-Source Options
Update your sources list to reflect the newly added repository.
sudo apt update
Next, install the latest NVIDIA drivers; below are examples with and without CUDA and proprietary and open-source versions.
Proprietary Nvidia Drivers
Install NVIDIA Drivers Without Cuda Support
sudo apt install nvidia-driver nvidia-smi nvidia-settings
Install NVIDIA Drivers With Cuda Support (Proprietary):
sudo apt install nvidia-driver cuda nvidia-smi nvidia-settings
Open-Source Nvidia Drivers
Install NVIDIA Drivers Without Cuda Support (Opensource):
sudo apt install nvidia-driver nvidia-kernel-open-dkms nvidia-smi nvidia-settings
Install NVIDIA Drivers With Cuda Support (Opensource):
sudo apt install nvidia-driver nvidia-kernel-open-dkms cuda nvidia-smi nvidia-settings
Note: The download is large and can take a while; given this is a general release, it is recommended to install all the drivers to avoid any issues or inconsistencies on your Debian desktop.
One good thing about the Nvidia repository installation is that if you forgot to remove the previous one, you will see a prompt for users with pre-existing installations before the installation continues. Select Yes to remove any existing drivers. Failure to do this may cause system instability. Once done, the installation will be complete.
Reboot
During the final phase of the installation, most users will typically see a message like the image below:
To activate the installation, reboot your system. You can use the following command after completing the installation:
sudo reboot
Situational: Install 32-bit Support for Nvidia Drivers
You can easily enable and install 32-bit support first. Then, install the 64-bit drivers mentioned earlier and follow these steps.
First, activate the 32-bit architecture using this command:
sudo dpkg --add-architecture i386
Update the APT-CACHE to reflect the changes to the architecture:
sudo apt update
Install 32-bit support, and remove the Cuda package “libcuda1-i386” for those users not requiring it.
sudo apt install libcuda1-i386 nvidia-driver-libs-i386
Reboot your PC:
sudo reboot
Confirm Nvidia Drivers Installation
Verify Nvidia Drivers Utilizing via CLI Command
First, verify the installation by running NVIDIA-SMI, as the manual installation steps showed beforehand.
nvidia-smi
If successful, you should see something similar too:
Verify Nvidia Drivers Utilizing via GUI
Alternatively, you can open the GUI for desktop users using the following command:
nvidia-settings
Or open the application icon located in the following path:
Activities > Show Applications > Nvidia X Server
Here, you should see a panel with all your Nvidia Driver settings available and system information. At this stage, for most, you have successfully installed the Nvidia Drivers of your choice on Debian.
Below are additional screenshots of the Nvidia Settings GUI Example Screenshots for users new to Linux and utilizing Nvidia Drivers:
Conclusion and Recap
With NVIDIA drivers installed on your Debian system, either through the default repository or the CUDA APT repository, you can ensure that your GPU is fully optimized for performance. The Debian repository provides a stable and easy-to-manage installation, while the CUDA repository offers access to the latest features and enhancements. Regularly updating your drivers, especially when using the CUDA repository, will help maintain optimal performance and compatibility, allowing you to make the most of your NVIDIA hardware on Debian.
Joshua
My Debian 12 was updated to nvidia driver 560 which killed it as I was running on 535 quite smoothly can I stop this from happening again .
Bob
Joshua
I had driver Linux-x86_64-535.216.01 working fine on my GTX1050 Ti , an update pushed the driver to 560 which does not work I have to start all over !
Bob
nvidia-detect was not available within non-free-firmware. I had to add “non-free” to make it visible to `sudo apt install`.
So, here is the entire command I propose to modify the corresponding one in this tutorial :
`sudo add-apt-repository contrib non-free-firmware non-free`
Thanks for the feedback Thibault, I’ll make a point to update the article.
Thank you so much for this tutorial and keeping it up-to-date! One problem though… The 32-bit support is at version 555, while the 64-bit support is at 560. Is there coming an update for it, or can I install 64-bit version 555?
Hello and thank you for the tutorial. Very well written and easy to follow.
Everything works well, but unfortunately, after rebooting, the system gets stuck on the login screen (keeps returning to it).
The system is a fresh Debian 12 KDE with Nvidia drivers including Cuda and Wayland. It’s a 2-monitor setup with a GTX 2080.
When I switch to X11 at login, I can sign in. However, the graphics are unusual: multiple backgrounds and windows on both monitors. I can open a CLI, the keyboard is QWERTY instead of QWERTZ. But that’s manageable.
As a Linux newbie, I’m a bit lost and hoping for some help here. Unfortunately, I couldn’t find anything suitable online 🙁
Best regards,
Elmar
Hello Elmar,
Thank you very much for your positive feedback on the tutorial. I’m glad to hear that it was easy to understand.
Regarding your problem: Unfortunately, the support for Wayland with two monitors on Debian 12 in combination with Nvidia drivers is still not optimal. Therefore, it would be advisable to switch to X11 (Xorg) for the time being.
Regarding the unusual graphics display (multiple backgrounds and windows on both monitors): It could be that something went wrong during the installation of the Nvidia drivers. Here are some steps you can try:
Check the driver installation: Did you install the Nvidia drivers fresh, or was there a previous installation that got overwritten? It is important to ensure that there are no remnants of old drivers.
Appropriate driver version: The GTX 2080 should work well with the latest Nvidia drivers (550-555). However, you could also try using a more stable version like Nvidia 535. Sometimes it helps to revert to an older, proven driver version.
To uninstall the current drivers and install a different version, you can use the following commands:
sudo apt-get purge nvidia-*
sudo apt-get install nvidia-driver-535
Check the configuration: Make sure the Xorg configuration files are set up correctly. Sometimes it helps to reset and regenerate the configuration files.
If these steps do not solve your problem, please let me know. There are other diagnostic and configuration options we can try.
Best regards,
Joshua
Hello Joshua,
Thank you very much for your tips. I have now tried several fresh installations and installed the drivers both via the repository using your method and directly as *.run files. The error remains the same. I’m now going to check under udev.d to see if all the rules are present (a tip from another forum pointed to a rule that is blocking the Nvidia driver). Setting up a new system doesn’t take long.
Under X11, the NVIDIA driver is present, but the regional settings are disabled. This has set the keyboard layout to English, and I cannot activate German or add the language, even though it was available before.
Wayland is important to me because I have monitors of different sizes, all of which can do 4k. I need to be able to scale them individually; otherwise, I can’t use the setup for graphics and video. I need the NVIDIA drivers to make full use of Davinci Resolve.
I will follow your tips and report back.
Best regards,
Elmar
Hi, Joshua,
Having an issue when I use Method 2.
After following the steps and arriving at:
`sudo apt install nvidia-driver nvidia-smi nvidia-settings`
I get an error claiming the installation failed due to unmet dependencies:
`nvidia-alternative : Depends: glx-alternative-nvidia (>= 1.2) but it is not installable`
`E: Unable to correct problems, you have held broken packages.`
This is on a fresh install of Debian 12. Any ideas?
I have a similar error!
Hello Joshua!
I have an issue when I use Method 2 the similar like Mat.
How you can see on Nvidia’s website:
https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/
the latest version of nvidia-driver, nvidia-msi and nvidia-settings are 560.35.03-1.
But when I am using:
echo ‘deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /’ | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list,
and after this:
apt search nvidia-driver,
apt search nvidia-settinds,
apt search nvidia-smi,
I see that latest version of nvidia-driver and nvidia-settings are: 565.57.01-1 amd64,
and latest version of nvidia-smi is: 560.35.03-1 amd64.
565.57.01-1 is beta-version (how you can see on Vnidia website).
And when I try:
apt install nvidia-driver nvidia-smi nvidia-settings,
I receive error:
Packages with unsatisfied dependencies:
nvidia-smi : Dependencies: nvidia-alternative (= 560.35.03-1)
Dependencies: libnvidia-ml1 (= 560.35.03-1) but 565.57.01-1 will be installed
Recommends: nvidia-kernel-dkms (= 560.35.03-1) but 565.57.01-1 will be installed or
nvidia-kernel-560.35.03 or
nvidia-open-kernel-560.35.03 but it cannot be installed
E: Unable to troubleshoot, you have broken fixed packages.
P.S. I used your tutorial long time. But few days ago I received update 565.57.01-1 for nvidia and all broked.
I purged nvidia and tried install again like you wrote. And now I receive error.
Your Method 1 is work. Installing *.run-file from Nvidia work. But Method 2 not work.
Please, tell me how I can fix this, because Method 2 is the best.
Thank you!
How do I remove the NVIDIA APT so that I can install the default one?
Never mind. I figured it out.
Thanks, got me up to 545.23.08 on debain 12 sadly I think 550.40+ is required for the new 6GB 3050
Detected NVIDIA GPUs:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA107 [GeForce RTX 3050 6GB] [10de:2584] (rev a1)
Checking card: NVIDIA Corporation GA107 [GeForce RTX 3050 6GB] (rev a1)
Uh oh. Your card is not supported by any driver version up to 545.23.08.
A newer driver may add support for your card.
Newer driver releases may be available in backports, unstable or experimental.
Guess I am risking the vendor run/installer
Just in case anyone with the same card finds this comment.
I can confirm I got the 550.40.x drivers directly from the nvidia run script on the nvidia website installed and they work fine so far on Debian 12
Thanks, Billy, for posting the feedback.
Currently I have this as a method for Fedora Nvidia Drivers installation, as currently Nvidia and Fedora from 38 onwards is a complete mess. I will add the same method for Debian as well as an optional back up method if all else fails.
What driver version from Nvidia APT PPA will work with the latest stable Debian kernel 6.1.0-18 ?
For example version 535.104.12 does not work.
It worked perfectly. I’ve chosen the option “Install NVIDIA Drivers Without Cuda Support (Proprietary)”.
Normally I would never leave comment on a website/blog/forum. You’ve helped me we with a problem that I have been struggling for over 5 years, now I can finally connect to a monitor with HDMI. None of the other solutions provided on the internet worked for me (Connect Debian to external monitors, while having a hybrid GPU (Nvidia/Intel)). The only resort I had, was to choose Linux Mint.
Many thanks, keep this good work alive!
Thanks Anon for the feedback, glad it worked out. 🙂
Thank you for the tutorial. It helps a lot. The only thing missing is the fact that nvidia driver may not work properly if you have secure boot enabled in your bios settings.
Thank you very much. Now everything working good. Because nvidia-driver from Debian repository not working good.
Thank you again!