Installing NVIDIA drivers can be a kaleidoscope of nightmares for new Debian users. It’s a choose your own adventure game riddled with pixelated pitfalls and binary baddies. Fear not, brave adventurers, for with courage and cunning, you’ll emerge victorious, sometimes.

Adventurers, heed my warning! Before you embark on the noble quest of installing NVIDIA drivers, remember to purge the remnants of the past!

Leaving old drivers to linger is like venturing into a dungeon without clearing the cobwebs: crashes lurk behind every frame, and glitches wait to ambush your performance. Don’t let the ghosts of driver versions past haunt your system.

But no matter your path, the perils remain:

  • The DKMS Dragon: This ferocious beast breathes fire upon stable systems, forcing them to perform painful metamorphoses at boot.
  • The Kernel Kraken: This tentacled terror lurks in the depths, dragging your performance down to the abyss with its incompatible depths.
  • The Dependency Desert: A vast wasteland where missing packages are the only mirage, and frustration the only oasis.

Let the NVIDIA Driver Labyrinth commence!

Have questions about your Linux setup? Ask in our forums.


ADVENTURE FLOW – COMMON SCENARIOS

Fresh Debian install and you want a working system?

  • Step 0 > A

Fresh Debian install and you want to upgrade CUDA?

  • Step 0 > A > D

Installed the drivers with APT and want to use the latest driver?

  • Step 0 > F > B

You want to install the NVIDIA driver with a real-time kernel. Really?

  • Step 0 > C

STEP ZERO – SKIP THIS AT YOUR OWN PERIL

The first thing we’re going to do is add our user to the sudo group, exit, and log back in. 

su
usermod -aG sudo username

Add the contrib and non-free app repositories.

sudo apt install software-properties-common
sudo add-apt-repository contrib non-free

Now add the i386 architecture with dpkg followed by an apt update. 

sudo dpkg --add-architecture i386
sudo apt update 

Install dkms, kernel headers, and build essentials. 

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

Create a file called blacklist.nouveau.conf, populate it with the following and save. 

nano /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0

Update initramfs.

sudo update-initramfs -u

A. NVIDIA DRIVER INSTALL – APT

Install nvidia-driver nvidia-cuda-toolkit using apt.

sudo apt install nvidia-driver nvidia-cuda-toolkit

Reboot the system.

sudo reboot now

Verify the installation by checking the NVIDIA X Server Settings utility. 


B. NVIDIA DRIVER INSTALL – *.RUN FILE

Download the production, new feature, or beta driver from nvidia.com

Make the *.run file executable using chmod. 

chmod +x *.run

Run the executable using sudo 

sudo ./*.run

The latest drivers can be installed without stopping the X server. 


You may encounter Nouveau warnings, but if you completed the step 0 of this guide, they can be safely ignored. 


Install the 32-bit libs.


Rebuild initramfs.


Say no to the X configuration utility and reboot the system. 

sudo reboot now

Verify the installation by checking the NVIDIA X Server Settings utility. 


C. NVIDIA DRIVER INSTALL – REAL-TIME KERNEL

Find your running kernel with uname -a 

uname -a

Locate the real-time image using apt and install it. 

apt search linux-image-YOUR_KERNEL_VERSION_NUMBER_DIGITS
sudo apt install linux-image-YOUR_KERNEL_VERSION_NUMBER_DIGITS-rt-amd64

Reboot the system and confirm it’s running the Real Time kernel.  

sudo reboot now

Now install dkms, kernel headers, and the build-essential packages with apt. 

sudo apt install dkms linux-headers-$(uname -r) build-essential

Change to superuser and set IGNORE_PREEMPT_RT_PRESENCE to 1. 

su
export IGNORE_PREEMPT_RT_PRESENCE=1

Download the production, new feature, or beta driver from nvidia.com

Make the run file executable using chmod. 

chmod +x *.run

Launch the executable using sudo 

sudo /*.run

The latest drivers allow you to install them without stopping the X server. 


You may encounter Nouveau warnings, but if you completed the step 0 of this guide, they can be safely ignored. 


Install the 32-bit libs.

Register with dkms. 


If you try to rebuild the initramfs this will happen, we’re going to do it later so go ahead and continue. 


Say no to the X configuration


Exit superuser and manually update initramfs

exit
sudo update-initramfs -u

Reboot the system. 

sudo reboot now

Verify the installation by checking the NVIDIA X Server Settings utility. 


D. CUDA UPGRADE – APT

Download the cuda keyring from nvidia and install it with dpkg.  

wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb

Run sudo apt update followed by apt install cuda toolkit 12 3. 

sudo apt update
sudo apt install cuda-toolkit-12-3

Open your bashrc and add the following lines. 

nano  ~/.bashrc 
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

Log out and back into the session.

exit

E. CUDA UPGRADE – UNINSTALL

You can uninstall CUDA by purging the keyring and toolkit followed by an autoremove.  

sudo apt purge cuda-keyring cuda-toolkit-12-3
sudo apt autoremove 

F. NVIDIA / CUDA UNINSTALL – APT

Uninstall NVIDIA and CUDA drivers by purging nvidia and cuda followed by an autoremove.

sudo apt purge nvidia* and cuda*
sudo apt autoremove 

G. NVIDIA UNINSTALL – *.RUN FILE

Locate the runfile you installed the drivers with (that you didn’t accidentally delete), and use the –uninstall flag. 

sudo ./*.run --uninstall 

A DEED WORTHY OF LEGEND!

The NVIDIA driver installation gauntlet lies behind you, a pixelated battlefield strewn with vanquished bugs and conquered dependencies. And now, as you stare at your desktop, once a glitching battlefield, now a haven of smooth-rendered beauty, a wave of triumph washes over you.

Have questions about your Linux setup? Ask in our forums.

VennStone

View all posts

Add comment