How to Install NVIDIA Drivers using Debian Repository

Nvidia Corporation is an American technology company which specializes at designing graphics processing units (GPUs) for the gaming, cryptocurrency and a system on a chip unit (SoCs) for the mobile computing and automotive market. For those in possession of PC running Debian operating system and have Nvidia graphics card, you need to install the drivers for optimized hardware acceleration of OpenGL applications via a direct-rendering X server. This article I will show you how to install the latest version of NVIDIA driver using the Debian 9 repositories.

To identify your system NVIDIA GPU codename of the installed video card, use lspci command.

$ lspci | grep -E "VGA|3D"
01:00.0 3D controller: NVIDIA Corporation GK107M [GeForce  GT 750M] (rev a1)

This will tell you whether you have Nvidia graphics card on your system.

Installing Nvidia Drivers

After identifying, we can now head to the installation section of graphics driver on Debian 9. Note that multiple precompiled driver versions are available for Debian 9 "Stretch". As of stretch Debian release, you don't need nvidia-xconfig anymore, and a xorg.conf file is not needed either in the most situation. Everything should just work out of the box.

Since the drivers are available on the  "contrib" and "non-free" repository components. Add them to your  /etc/apt/sources.list file.

$ sudo su -
# echo "deb stretch main contrib non-free" >> /etc/apt/sources.list

Then update your cache index and do a system upgrade.

$ sudo apt-get update
$ sudo apt-get upgrade && sudo apt-get dist-upgrade
$ sudo reboot

After all above is successfully executed, install the appropriate linux-headers and kernel module packages:

$ sudo apt install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//') nvidia-driver nvidia-kernel-dkms

This will install the nvidia-driver package. DKMS will build the nvidia module for your system, via the nvidia-kernel-dkms package.

For the nouveau Xorg display driver to be blacklisted, restart your system. Nvidia driver will be loaded fine after.

$ sudo reboot

Get Nvidia driver version

Use nvidia-smi command which reads temps directly from the GPU without the need to use X at all. For this, run:

$ sudo nvidia-smi

It will give you information about NVIDIA driver version. NVIDIA module should be properly loaded for this to work.

Get module version

If execution of the above command fails for any reason since NVIDIA module couldn't be loaded, you can always see NVIDIA version number by directly retrieving nvidia.ko module using the modinfo Linux command. The below command will check for NVIDIA driver version under your currently running kernel:

nbsp;modinfo /usr/lib/modules/$(uname -r)/kernel/drivers/video/nvidia.ko | grep ^version version: 390.77

Creating empty xorg.conf

For systems, you may need to remove xorg.conf file to Nvidia to work properly. Use the commands below for this.

$ sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old
$ sudo touch /etc/X11/xorg.conf

And reboot the system.

Manually creating xorg.conf

If you need to modify your xorg.conf for Nvidia driver, a sample configuration is provided below.

~$ cat /etc/X11/xorg.conf
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"

Section "Files"

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       30.0 - 80.0
    VertRefresh     55.0 - 75.0
    DisplaySize     400 225
    Modeline       "1920x1080_60.00"  172.80  1920 2040 2248 2576  1080 1081 1084 1118  -HSync +Vsync
    Option         "DPMS"

Section "Device"
    Identifier     "Device0"
    BusID          "PCI:1:0:0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Viewport    0 0
        Depth       24
        Modes      "1920x1080_60.00"

The configuration shown is for a 1920x1080 resolution. Key things to note.

  • Specify the correct HorizSync and VertRefresh

You can generate Modeline using:

nbsp;gtf 1920 1080 60

Then add name Modeline in Modes. Restart Xorg server after changing it. A reboot of the system may be necessary as well.

5 Comments... add one

  1. ive been tryn to install nvidia drivers on parrot os and was at it for ages until a simple command installed it for me.i'm just a noob to this at the moment but i think if it should work on parrot os it should work on kali linux to??correct me if im wrong tho.heres the command :
    sudo apt-get install nvidia-driver nvidia-kernel-dkms

  2. Thanks for your article. I am running Ubuntu 19.04 and I get the blanc screen after reboot. I see many other people get the same issue. Can you please be more specific on how to manually create the xorg.conf file? Can I just paste the text into the file using vim?

  3. Thanks so much for this. Been trying to find the secret sauce to getting nvidia working on AWS gpus and this did it! Thanks!!!!


Leave a Comment