NVIDIA, with the rise in popularity of Large Language Models (LLMs), has managed to ride this wave of hype—since LLMs are deeply tied to GPU computations—NVIDIA has firmly secured its position as the leader in the GPU market, leaving AMD GPUs far behind. However, for Linux users, installing and configuring NVIDIA GPU's drivers still gives many goosebumps. In this article, I’ll cover key concepts about NVIDIA drivers and will show an easy way to install them on Debian OS.
Linux kernel & Drivers
When you first install an OS using a graphical installer, you might notice the graphics of Installer look a bit rough or stretched, kind of like this:
After installation is finished and you boot for the first time, everything usually looks fine in terms of resolution. That’s because, during the installation of Debian or any other OS, the Linux Kernel with necessary drivers are installed.
Here’s how it works: you install your OS → the OS also installs the Linux kernel (as it can't operate without it) → the Kernel doesn’t come alone—it has kernel modules, which are essentially the Linux drivers for your PC's hardware pieces.
During installation, the installer doesn’t connect to the Linux kernel source repository to fetch the kernel for your system; instead, it connects to its own repository, where the Linux kernel is packed, optimized, and tuned to work harmoniously with the system. In case of Debian:
The kernels in Debian are distributed in binary form, built from the Debian kernel source. It is important to recognize that Debian kernel source may be (and in most cases is) different from the upstream (or "pristine") kernel source, distributed from www.kernel.org and its mirrors. Due to licensing restrictions, unclear license information, or failure to comply with the Debian Free Software Guidelines (DFSG), parts of the kernel are removed in order to distribute the source in the main section of the Debian archive. (Source)
This piece of information actually puts a light on that age-old question, or dilemma, or whatever you want to call it:
"WHY DID HARDWARE X WORK ON WINDOWS BUT NOT ON DEBIAN?" Well, because Windows uses its own kernel. Second question: "WHY DID HARDWARE X WORK ON UBUNTU BUT NOT ON DEBIAN?" The answer is that Ubuntu prioritizes usability and universality over security, so their developers policies about adding some stuff to their default package repos is definitely less strict than Debian's ones.
Let’s put pieces of information together. Linux kernel has kernel modules and they are providing your system with possibility to use various hardware components of your PC, because drivers per se are kernel modules.
You can explore the drivers available on your system by running ls /lib/modules/$(uname -r)/kernel/drivers/
($(uname -r)
part retrieves the exact version of the kernel currently in use by your system; there might be multiple kernel versions installed, especially if you regularly update your system packages, as the kernel version updates whenever a new kernel release becomes available).
When I run lspci -k | grep -A 3 NVIDIA
, I can see that for my NVIDIA video card, the kernel driver in use is Nouveau. By default, Debian provides Nouveau drivers for NVIDIA graphics cards because they are open-source and non-proprietary, unlike NVIDIA’s official drivers.
I mentioned that Debian "provides" these drivers, and I’d like to elaborate on this. On Debian, the Linux kernel is not just a standalone "file/object" pulled during installation - it is a package. This package is called linux-image-*
, where the asterisk represents a specific target build of the kernel package, such as cloud
, amd64
, rt
, and the version of this package. This kernel package linux-image-*
includes built-in modules, like the Nouveau driver, to ensure hardware compatibility out of the box. You can actually check which package provides a specific kernel module with dpkg-query
command. In case of nouveau driver for NVIDIA video card the command will be:
dpkg-query -S /lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nouveau/nouveau.ko
Even though there’s nothing wrong with Nouveau drivers for NVIDIA GPUs— you can use them and enjoy very good performance (many Linux users even prefer them over NVIDIA’s proprietary drivers)—if you plan to use your NVIDIA GPU for AI, machine learning, or LLMs, you will absolutely need NVIDIA’s proprietary drivers. There’s no way to access CUDA without these drivers. Plus, it’s always nice to fully utilize the potential of such high-cost hardware like GPUs, and this level of optimization is often only achievable with the manufacturer’s proprietary drivers
NVIDIA documentation & NVIDIA recommended drivers.
The NVIDIA website can feel like a dark forest. If you go to the official NVIDIA site on the Download The Official NVIDIA Drivers | NVIDIA page, you’ll need to manually enter your NVIDIA device model. Here’s what’s suggested for my NVIDIA GeForce video card:
Let’s say I just pick the first one in the list, which has a nice description:
What is an NVIDIA Recommended Driver?
This driver meets the quality levels applied to Windows drivers that pass testing in Windows Hardware Quality Labs (WHQL), therefore providing the same attention to driver reliability, robustness, and performance for non-Windows operating systems (e.g., Linux).
Well that's nice that it was tested in some Windows Hardware Quality Labs, but I am searching for Linux drivers...well...whatever. If I click on the View button, I’m redirected to the Download page. There, you’ll see three tabs—click on Additional Information, and that’s where the installation instructions are hiding!
Installation instructions: Once you have downloaded the driver, change to the directory containing the driver package and install the driver by running, as root,
sh ./NVIDIA-Linux-x86_64-550.127.05.run
Seems very easy-peasy-lemon-squisy. But what is that .run
stuff? Executing something unknown with root privileges...boh. You can check this article to understand why it is not a very good idea.
On Linux systems, a .run
file is typically either a single binary executable or a shell script that includes a binary blob that can be installed (source). Essentially, any .run
file acts as an installer script that will make system-wide changes, since it specifies that it should be executed with root permissions. As I mentioned earlier, drivers are kernel modules, so this installer will build an additional kernel module for your OS. But what exactly will be inside this new kernel module? Download page of NVIDIA drivers does not mention any compatibility matrix with the kernel, so will this “magic” .run
file simply build version 550.x.x.x of the driver for my kernel? Or will it update my kernel to fit its needs? Well, I definitely don’t want my kernel updated!
If you don’t have a clear answer to questions above, that's reason enough NOT to run anything with sh some-cool-installer.run
on your Debian system! This isn’t just about the security risks with NVIDIA drivers or the possibility of some embedded nasty stuff—it’s about your Debian stability.
NVIDIA drivers are very close-source and even their license states clearly:
You may not reverse engineer, decompile, or disassemble the SOFTWARE provided in binary form, nor attempt in any other manner to obtain source code of such SOFTWARE
A link to the README instructions is available under the Additional Information tab on the download page.
Chapter 4 of this README is dedicated to installation of NVIDIA driver with this .run executable.
The .run file is a self-extracting archive. When executed, it extracts the contents of the archive and runs the contained nvidia-installer utility, which provides an interactive interface to walk you through the installation.
And here is about how Nvidia driver installation will communicate with your kernel:
When the installer is run, it will check your system for the required kernel sources and compile the kernel interface. You must have the source code for your kernel installed for compilation to work. On most systems, this means that you will need to locate and install the correct
kernel-source
,kernel-headers
, orkernel-devel
package; on some distributions, no additional packages are required.
In a default Debian setup (the set of packages you get pre-installed), you’ll only have the package linux-image-*
(which contains kernel itself and default kernel modules-drivers, as it was mentioned above)—without the kernel headers or developer libraries preinstalled. Why is that? First, you need to understand what Linux headers are and why exactly NVIDIA drivers need them.
If you're using your Debian system in the "Debian way," you’re probably installing packages mostly from Debian repositories. Since these packages (including the kernel) come from Debian’s repos, they’re built and tested to work together. The open-source Nouveau drivers, for instance, are part of the linux-image-*
Debian package, together with the Linux kernel itself. However, for external, especially third-party software that has to communicate with kernel, your kernel is a "black box." These programs can’t communicate with it directly. That’s where Linux headers come in. Linux headers can be roughly explained as "the programming interface needed to interact with the Linux kernel" - if a software needs to communicate with the kernel, Linux headers are needed to install/build it.
So, naturally, the installation process for NVIDIA drivers requires having Linux headers. However, Linux headers aren’t the only requirement for installation. And the READMI file contains all the additional instructions.
If you don’t fully understand these instructions and the steps involved, then installing NVIDIA drivers this way might not be for you. You can, of course, experiment (snapshotting tools are great for these kinds of experiments).
I won’t provide a guide on how to do it, nor I will install NVIDIA drivers in this NVIDIA Recommended way on my Debian. I prefer to manage my system "the Debian way," and installing drivers like this is not a Debian way at all. System's drivers are not just about getting them set up—it’s about maintaining them afterward. Installation might be straightforward, but maintenance is the real challenge, especially when it comes to system software and kernel updates & upgrades.
Besides, for my needs, I don’t need any bleeding-edge NVIDIA features that come with the latest versions of NVIDIA drivers.
Luckily, there is Debian way of installing these drivers, and in this article I will be following it.
NVIDIA drivers installation: "Debian" way.
The procedure for installing NVIDIA drivers is covered in detail in NvidiaGraphicsDrivers - Debian Wiki. I mentioned the "Debian way" of drivers installation, and actually it is a broad term related not only to drivers installation, and if you’re using a Debian distro, I recommend familiarizing yourself with this term. You can find many details here.
In the documentation, the section you need is "Debian 12 Bookworm" (I’m assuming you’re using this version of Debian, the latest one). The version of the NVIDIA drivers installed by following that guide will be 535.183.01. Yes, this version is slightly older than the "official" driver available on NVIDIA’s website, which I mentioned earlier. However, this is a trade-off: you sacrifice a bit in terms of the driver’s newness, but you gain system stability and ease of installation.
The "Debian way" of installing NVIDIA drivers is about installing them as a single package in a default way - using apt
. However, as I mentioned, NVIDIA’s software is proprietary and very close-source, so Debian keeps this type of third-party software in a separate component of its package repositories.
If you’re unfamiliar with how Debian packages its software, apt
for you is a sort of "black box", and the sources.list
file seems completely incomprehensible, I highly recommend checking out these articles before proceeding: about Debian releases, about Debian software installation - repositories and repository components.
The package containing the NVIDIA drivers is located in the "non-free" component of Debian’s package repositories. The term "non-free" doesn’t mean you need to pay to use the packages found there; rather, it refers to the nature of the software, as it includes closed-source code that isn’t publicly accessible. By default, "non-free" component is excluded from the list of sources that apt uses to fetch and install packages onto your system.
STEP I. Add the "non-free" component to the list of sources for apt
:
$ sudo vim /etc/apt/sources.list
#add non-free:
deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
#this step is important: you have to make apt aware of changes made to this file:
$ sudo apt update
NB! If you have your kernel package linux-image-*
installed not from Debian bookworm repo but from Debian backports repo, you will need to install NVIDIA drivers also from there! This is due to the various dependencies linked to kernel and its version of NVIDIA drivers package!
STEP II. Check if your OS is booted with Secure Boot. Rule of the thumb - if you use a Dual Boot with Windows 11, 99% is that Secure Boot is enabled!. To be sure, run sudo mokutil --sb-state
. If you see this:
$ sudo mokutil --sb-state
SecureBoot enabled
If you do not understand what the Secure Boot is about, you will need to study it. I wrote the detailed article about Secure Boot and Debian, specifically from the perspective of how it impacts kernel modules and NVIDIA drivers. As an alternative, you always can find all answers in Debian Documentation - SecureBoot - Debian Wiki.
NB! If you have Secure Boot enabled and proceed with the following steps, your installed NVIDIA drivers will never load until you have them signed. The NVIDIA drivers signing is out of the scope for this article!
If you don’t know how to sign kernel modules for UEFI, I strongly recommend reading the Debian documentation or the article I mentioned. Once you’ve learned how to handle Secure Boot and signed your modules, you can return here to continue with the installation steps. FYI, in this article, I am installing drivers on systems that has Secure Boot enabled.
STEP III. You need to check if your system uses dracut
. Dracut is the low-level tool that is used to create an initial image used by the kernel for preloading the block device modules (such as IDE, SCSI or RAID) which are needed to access the root filesystem, mounting the root filesystem and booting into the real system (Source). This "job" can be done not only by dracut
, but also by initramfs-tools
. You can find out "who" does this job for your system with dpkg -l | grep -E 'dracut|initramfs-tools'
. If you see in the output dracut
, you have to:
- Make a dracut configuration file
/etc/dracut.conf.d/10-nvidia.conf
(you can actually name it anything you like, as long as it ends in.conf
) with the following contents:
install_items+=" /etc/modprobe.d/nvidia-blacklists-nouveau.conf /etc/modprobe.d/nvidia.conf /etc/modprobe.d/nvidia-options.conf "
- Note the spaces between quotes and characters.
- The modprobe.d files referenced here will be added by the
nvidia-driver
package.
STEP IV. Install nvidia-driver package that will bring you your system NVIDIA drivers
$ sudo apt update
$ sudo apt install nvidia-driver firmware-misc-nonfree
# NB!!!If your linux-image-* package is from bookworm backports, you must install nvidia-driver package from this repo to avoid broken dependencies error!
# sudo apt install -t bookworm-backports nvidia-driver
If you did not blacklist nouveau drivers before installation, at certain point during installation you will see a warning message in the terminal (likely on the blue background):
Conflicting nouveau kernel module loaded
The free nouveau kernel module is currently loaded and conflicts with the non-free nvidia kernel module
The easiest way to fix this is to reboot the machine once the installation has finished
So, you just need to press Enter to proceed, the solution is the reboot - once installation has finished, reboot your system (sudo reboot
).
When you are booted again, run nvidia-smi
command.
This is my output:
If you see something similar (and no errors), congratulations! You have successfully installed the NVIDIA drivers. For additional confirmation, you can list your PCI devices and the kernel modules in use (loaded drivers) by running lspci -k | grep -A 3 NVIDIA
.
Top comments (0)