How to Install Nvidia Drivers on Debian 11/10

Debian users know that the releases mean stability, so instead of installing Nvidia Drivers by default and keeping them updated when new releases arrive, you will find the Nouveau open-source graphics device driver installed on your system for Nvidia video cards for desktop users. For the most part, this is acceptable; however, if you use your Linux system for graphical design or gaming, or maybe you require Cuda support for development or headless driver support, you may need better drivers.

The following tutorial will teach you how to install Nvidia Graphic Drivers using Debian’s repositories and to install Nvidia drivers directly from Nvidia repositories, with open-source and proprietary drivers available.

Important Notice

The following tutorial was done with a Debian 11 Bullseye release and example images taken, but it was tested on Debian Buster. In the future, if Debian makes any changes to break the tutorial for one of the distribution versions, please place a comment for me to investigate so I can update the tutorial.

Please note that other distributions, such as MX Linux, may find both methods to work exactly as they would on a standard Debian system. Still, you may need to do extra steps.

Recommended Steps Before Installation

Before proceeding with the tutorial, ensuring your system is up-to-date with all existing packages is good.



sudo apt update

Optionally, you can list the updates for users who require review or are curious.

sudo apt --list upgradable

Proceed to upgrade any outdated packages using the following command.

sudo apt upgrade

Previous Nvidia Installations

Please note installing Nvidia drivers over the standard packages 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.

#1st Method Install NVIDIA Drivers – Debian Repository

Installation Pre setup

The first task is enabling the “contrib” and “non-free” repositories to your Debian repositories. This can be quickly done using the following commands.

First, add the contrib repository.

sudo add-apt-repository contrib

Now add the non-free repository.



sudo add-apt-repository contrib

Once added, update your repository list.

sudo apt update

Before installing any Nvidia drivers, you will need to 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 the following headers need to be installed.

sudo apt install linux-headers-amd64

32bit Debian systems, use the following command instead.

DO NOT USE THE BELOW COMMANDS IF YOU ARE ON A 64BIT SYSTEM.



32-bit non-PAE kernel:

sudo apt install linux-headers-686

32-bit PAE kernel:

sudo apt install linux-headers-686-pae

Install Nvidia Drivers

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

Now that Nvidia-detect is installed, run the command to check your current Nvidia Graphics Card:

nvidia-detect

The output has shown the machine in the example has a GeForce GTX 1650 card and that it is recommended to install the nvidia-driver package, but this is just a recommendation.



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.

Once installed, reboot your system.

reboot now

Once logged back in, run the “nvidia-smi” command to confirm the new Nvidia Drivers have been installed.

nvidia-smi

Install Nvidia Legacy Drivers

If your Nvidia Graphics card is quite old from 400 Series downwards, you will need to 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 -y

Once complete, do not forget to reboot your system.



sudo reboot now

Next, run the “nvidia-smi” command to verify the installation.

nvidia-smi

The 340 series can technically be installed; however, it is no longer supported, and several major security flaws exist in those drivers. It is not advised to install these drivers if you need to replace 390xx with 340xx, but Debian does not recommend this.

#2nd Method – Install Nvidia Drivers with Nvidia Repository

The second method will install the latest drivers for your desktop or server using the Cuda repository. I would recommend using these drivers since when an update is released, you will receive it straight away. This is good for security and performance since Nvidia often does new releases, and now you can install the open-source option.

Determine your Graphics Card

The first step for users with aging NVIDIA Graphics cards is to determine what it is and if it is supported, users with brand new cards can skip this part as there is no doubt they will be supported.

First, find your graphics card module.

lspci | grep -e VGA

Example output:



03:00.0 VGA compatible controller: NVIDIA Corporation TU117 [GeForce GTX 1650] (rev a1)

Importing Nvidia Repository

First, ensure you install the following packages, which may be already installed.

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.

Import GPG key for Debian 11 Bullseye:

curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/3bf863cc.pub | gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg

Import GPG key for Debian 10 Buster:

curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/3bf863cc.pub | gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg

Second, import the repository for your Debian system, and again ensure you import the correct one to match your Debian distribution version.

Import Nvidia Repository for Debian 11 Bullseye:

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

Import Nvidia Repository for Debian 10 Buster:

echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list

Enable the CONTRIB repository. Run this even if you already have it enabled to be safe.

sudo add-apt-repository contrib

Installing Nvidia Drivers – Proprietary or Opensource options

Update your sources list to reflect the newly added repository.

sudo apt update

Next, install the latest NVIDIA drivers.



Install NVIDIA Drivers Without Cuda Support (Proprietary):

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

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 that 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 would 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.

Once the installation is complete, you will be prompted to reboot your PC to enable the NVIDIA drivers.

Example:



example reboot for nvidia drivers installation to avoid conflict with nouveau kernel

Reboot your system once done.

sudo reboot

Verify the installation by running NVIDIA-SMI as the manual installation steps showed beforehand.

nvidia-smi

Example output:

example nvidia smi command output for nvidia drivers on debian linux desktop

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



Example output:

example nvidia settings gui on debian linux desktop

Install 32-bit Support for Nvidia Drivers

32-bit support can be easily enabled and installed first. Install the 64-bit drivers above, then proceed with the following steps.

First, enable 32-bit architecture.

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


Not what you were looking for? Try searching for additional tutorials.

19 thoughts on “How to Install Nvidia Drivers on Debian 11/10”

  1. This is the hard way. I go to Nvidia direct. Get the driver of choice/need and install VIA command line root (the old school unix/linux way). But if you need to have the debian configured driver or a new person, this might be the better way.

    Reply
  2. I added the contrib and non-free sources, and installed the headers, but when I try to install the driver I get this:

    apt install nvidia-driver
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Package nvidia-driver is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    
    E: Package 'nvidia-driver' has no installation candidate
    

    I get the same error when I try to install nvidia-detect.
    Debian 11, fresh install, apt is all updated and upgraded.

    I haven’t tried installing directly from Nvidia, yet. That’ll be my next step, I guess.

    Any suggestions would be appreciated.

    Reply
    • Hi Andrew,

      What graphics card is it, may I ask?

      If it’s recent, installing manually is often better. You can also pull it from Sid/Unstable repository; however, when I created the tutorial, I found it was 1 version behind the latest released by Nvidia.

      Secondly, it was far easier to install manually than the Sid/Unstable alternative since there are dependencies that needed to be manually downloaded, making it very confusing and tricky for the average desktop user.

      Let me know. I am genuinely interested and will update the tutorial as well.

      Thanks for the message. I appreciate it.

      Reply
      • I have a GeForce RTX 3060, but it turned out to be user error. I added contrib and non-free to the deb-src line, instead of the deb line. Once I fixed that it worked just fine.

        Thanks for the great tutorial!

        Reply
  3. When I type Nvidia-SMI it says “NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running” When I type: apt install linux-headers-amd64, it says “linux-header-amd64 is already on the newest version (5.10.70-1) and when I type: apt install nvidia-driver linux-image-amd64, it says ” nvidia-driver is already running the newest version (460.91.03-1). But for some reason it’s still not communicating, can you please help. Also how would I change the resolution if I do not have gnome installed? My monitor is a 3440×1440. Thanks.

    Reply
    • Thanks for the message, Chris.

      The monitor size should have nothing to do with it. Secondly, the tutorial uses a stock standard Debian 11 fresh installation.

      Sometimes alternative display managers or desktop environments can cause issues since there are many options I have not tested them all except GNOME that comes with Debian 11.

      Secondly, are you trying to install the manual .run file? Since the command is

      sudo apt install linux-headers-$(uname -r) build-essential libglvnd-dev pkg-config
      

      not

      sudo apt install linux-headers-amd64
      

      Let me know how you go. Thanks

      Reply
  4. Hi i fighting with this case all night it never works with deb-src and with manual installation.

    Please add to you subject extra information. UEFI Boot manager from WINDOWS with install double system, blocking accesss kernel linux to nvidia graphic cards. Needs turnoff UEFI. before i did, i getting message from apt-get install nvidia-driver — Missing files /usr/……  it was anoying and missunderstand with problem of nouveau

    Reply
    • Thanks for the feedback, will keep this in mind with the tutorials, glad to hear you got it sorted.

      Cheers.

      Reply
  5. Very good guide. But before installation I was obliged to uninstall previous drivers:
    sudo apt –purge remove nvidia.*

    Reply
    • Thanks for the message, Alex.

      A good call-out on removing the previous drivers if installed. I will add this option/warning to my graphic card installs going forward. Glad you got it sorted, and the tutorial helped.

      Cheers.

      Reply

Leave a Comment