- Install Nvidia Drivers on Debian/Ubuntu
- Ensure the GPUs are Installed
- Disable Nouveau
- Blacklist Nouveau in Modprobe
- Update Grub to Blacklist Nouveau
- Prerequisites
- Close X Server
- Install Drivers Only
- Troubleshoot the Nvidia Installer
- Other Reference Material
- Test the Nvidia Installation
- Multiple Driver Failure
- Restart X Server
- How to Install Nvidia Drivers on Debian
- Install Nvidia Drivers Via Debian Repository
- Step 1: Enable Non-Free Repositories
- Step 2: Install Nvidia Detect
- Step 3: Detect and Install Drivers
- Install Nvidia Drivers Via Official Nvidia.com Package
- Step 1: Enable Non-Free Repositories and Install Nvidia Detect
- Step 2: Detect Nvidia Card
- Step 3: Download Suggested Drivers
- Step 4: Install Driver Prerequisites
- Step 5: Disable Default Drivers
- Step 6: Reboot to Multi-User Login
- Step 7: Install Nvidia Drivers
- Step 8: Enable GUI
Install Nvidia Drivers on Debian/Ubuntu
This section will provide instructions on installing Nvidia drivers in a Debian/Ubuntu environment, if the target servers have Nvidia GPUs.
Ensure the GPUs are Installed
Ensure that the lspci command is installed (which lists the PCI devices connected to the server):
sudo apt-get -y install pciutils
Perform a quick check to determine what Nvidia cards have been installed:
The output of the lspci command above should be something similar to:
00:02.0 VGA compatible controller: Intel Corporation 4th Gen . 01:00.0 VGA compatible controller: Nvidia Corporation .
If you do not see a line that includes Nvidia, then the GPU is not properly installed. Otherwise, you should see the make and model of the GPU devices that are installed.
Disable Nouveau
Blacklist Nouveau in Modprobe
The nouveau driver is an alternative to the Nvidia drivers generally installed on the server. It does not work with CUDA and must be disabled. The first step is to edit the file at /etc/modprobe.d/blacklist-nouveau.conf . Something like:
Then, run the following commands:
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf sudo update-initramfs -u
Update Grub to Blacklist Nouveau
Backup your grub config template:
sudo cp /etc/default/grub /etc/default/grub.bak
Then, update your grub config template at /etc/default/grub . Add rd.driver.blacklist=grub.nouveau and rcutree.rcu_idle_gp_delay=1 to the GRUB_CMDLINE_LINUX variable. For example, change:
GRUB_CMDLINE_LINUX="quiet rd.driver.blacklist=grub.nouveau rcutree.rcu_idle_gp_delay=1"
Then, rebuild your grub config:
sudo grub2-mkconfig -o /boot/grub/grub.cfg
Prerequisites
The following prerequisites should be installed before installing the Nvidia drivers:
sudo apt-get -y install linux-headers-$(uname -r) make gcc-4.8 sudo apt-get -y install acpid dkms
Close X Server
Before running the install, you should exit out of any X environment, such as Gnome, KDE or XFCE. To exit the X session, switch to a TTY console using Ctrl-Alt-F1 and then determine whether you are running lightdm or gdm by running:
sudo ps aux | grep "lightdm|gdm|kdm"
Depending on which is running, stop the service, running the following commands (substitute gdm or kdm for lightdm as appropriate):
sudo service lightdm stop sudo init 3
Install Drivers Only
To accommodate GL-accelerated rendering, OpenGL and GL Vendor Neutral Dispatch (GLVND) are now required and should be installed with the Nvidia drivers. OpenGL is an installation option in the *.run type of drivers. In other types of the drivers, OpenGL is enabled by default in most modern versions (dated 2016 and later). GLVND can be installed using the installer menus or via the --glvnd-glx-client command line flag.
This section deals with installing the drivers via the *.run executables provided by Nvidia.
To download only the drivers, navigate to http://www.nvidia.com/object/unix.html and click the Latest Long Lived Branch version under the appropriate CPU architecture. On the ensuing page, click Download and then click Agree and Download on the page that follows.
The Unix drivers found in the link above are also compatible with all Nvidia Tesla models.
If you’d prefer to download the full driver repository, Nvidia provides a tool to recommend the most recent available driver for your graphics card at http://www.Nvidia.com/Download/index.aspx?lang=en-us.
If you are unsure which Nvidia devices are installed, the lspci command should give you that information:
Download the recommended driver executable. Change the file permissions to allow execution:
chmod +x ./NVIDIA-Linux-$(uname -m)-*.run
Run the install. If you are prompted about cryptographic signatures on the kernel module, answer Sign the Kernel Module and then Generate a new key pair. At the end, DO NOT update your X config if it asks. Note that the following attempts to diagnose a common problem where the installer fails to correctly detect and deal with the situation where the kernel has been signed, but signed kernel modules are not required.
grep CONFIG_MODULE_SIG=y /boot/config-$(uname -r) && \ grep "CONFIG_MODULE_SIG_FORCE is not set" /boot/config-$(uname -r) && \ sudo ./NVIDIA-Linux-$(uname -m)-*.run -e || \ sudo ./NVIDIA-Linux-$(uname -m)-*.run
If there are any issues with the installation, the installer should notify you where the log is kept; the default location is usually:
Troubleshoot the Nvidia Installer
One common issue with installing the Nvidia driver is that it will fail out because the Nvidia driver taints the kernel. The issue is that the driver is not signed and the default install does not attempt to sign it, but the kernel is expecting a signed driver. If you encounter this error, you should re-run the install in expert mode:
When prompted about cryptographic signatures on the kernel module, answer Sign the Kernel Module and then Generate a new key pair. Again, at the end, make sure to answer No when asked if you want the installer to update your X configuration.
This situation is usually detected during the above install step, but if there are issues, you can run this command separately.
Another issue that may arise is that if the kernel development version and the system kernel version don’t match up, the Nvidia driver install will not proceed after accepting the license. To fix this issue:
sudo apt-get update && sudo apt-get install linux-headers-$(uname -r) sudo reboot now
Other Reference Material
Nvidia has a large readme online at:
http://us.download.nvidia.com/XFree86/Linux-//README/index.html
For example, on x86 for version 375.26, the readme is online at:
http://us.download.nvidia.com/XFree86/Linux-x86_64/375.26/README/index.html.
Test the Nvidia Installation
After the Nvidia drivers are installed, you can test the installation by running the command:
Which should return something similar to:
+------------------------------------------------------+ | NVIDIA-SMI 361.42 Driver Version: 361.42 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 Quadro K1100M Off | 0000:01:00.0 Off | N/A | | N/A 44C P0 N/A / N/A | 8MiB / 2047MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
Multiple Driver Failure
If an error is returned, stating:
Failed to initialize NVML: GPU access blocked by the operating system
there may be multiple versions of the Nvidia drivers on the system. Try running:
dpkg --list | grep -E "cuda|nvidia"
Review any versions listed and remove them as needed. Also run:
locate libnvidia | grep ".so."
Confirm that the files all end with either a 1 or the version of the Nvidia driver that you installed, for example .375.21.
Restart X Server
If you had to stop the X Server to install your Nvidia driver, the simplest way to get back into X is to reboot the server:
How to Install Nvidia Drivers on Debian
Nvidia GPUs (Graphics Processing Units) have a wide variety of uses, from gaming, 3D rendering, and visualization, to cryptocurrency mining and machine learning. Keeping the drivers for these GPUs up to date ensures your system is performing at peak efficiency.
In this tutorial, we will guide you through the step-by-step process of installing Nvidia drivers on Debian 10.
- A system running Debian 10 (Buster)
- An account with sudo privileges
- Access to the terminal window
- A working Internet connection
Install Nvidia Drivers Via Debian Repository
The first method focuses on installing Nvidia drivers using Debian repositories. Follow the steps below to complete the installation.
Step 1: Enable Non-Free Repositories
1. Open the Linux’s Advance Packing Tool configuration file using a text editor. For example:
sudo nano /etc/apt/sources.list
2. Alter the configuration as necessary, so it contains the following lines:
deb http://deb.debian.org/debian/ buster main contrib non-free deb-src http://deb.debian.org/debian/ buster main contrib non-free deb http://security.debian.org/debian-security buster/updates main contrib non-free deb-src http://security.debian.org/debian-security buster/updates main contrib non-free deb http://deb.debian.org/debian/ buster-updates main contrib non-free deb-src http://deb.debian.org/debian/ buster-updates main contrib non-free
Note: Some of the lines listed above are already included in the configuration file as comments. Uncomment them by removing the pound symbol (#) at the start of the line.
3. Press Ctrl+X, then type Y and press Enter to save changes and exit the configuration file.
4. Update the system repository index:
Step 2: Install Nvidia Detect
Install the Nvidia Detect Utility with:
sudo apt install nvidia-detect
Step 3: Detect and Install Drivers
1. Use the Nvidia Detect Utility to check the model of your GPU and get a compatible driver recommendation:
2. Install the driver the utility recommends. The syntax is:
sudo apt install [driver name]
In our example, the name is nvidia-driver:
sudo apt install nvidia-driver
3. Type Y and press Enter to confirm the installation.
4. Once the installation completes, reboot your system with:
Install Nvidia Drivers Via Official Nvidia.com Package
This method allows you to manually download and install an Nvidia driver package from the official website.
Note: You have to be logged in as the root user on your system for this method to work.
Step 1: Enable Non-Free Repositories and Install Nvidia Detect
Start by going through steps 1 and 2 of the previous method. Enabling non-free and contrib repositories and install the Nvidia Detect Utility.
Step 2: Detect Nvidia Card
Use the following command to check your GPU model. Pay attention to the driver series number:
Step 3: Download Suggested Drivers
1. Navigate to the Nvidia driver download page and find the driver that matches the number as suggested by the Nvidia Detect Utility. In this example, we are looking for the legacy driver series 390:
Click the version number to go to the download page.
2. Click the DOWNLOAD button and download the driver package to your Home directory.
Step 4: Install Driver Prerequisites
Install the Nvidia driver compilation prerequisites by using:
apt -y install linux-headers-$(uname -r) build-essential libglvnd-dev pkg-config
Step 5: Disable Default Drivers
Before proceeding with the installation, disable the default nouveau GPU driver:
1. Create and open a new configuration file. We used nano:
nano /etc/modprobe.d/blacklist-nouveau.conf
2. Add the following lines to the file:
blacklist nouveau options nouveau modeset=0
3. Save the changes and exit. In nano, press Ctrl+X, then type Y and press Enter.
4. Rebuild the kernel initramfs with:
Step 6: Reboot to Multi-User Login
1. Since the default GPU drivers are now disabled, switching to a text-based login allows you to install Nvidia drivers without using the GUI. Enable the text-based, multi-user login prompt:
systemctl set-default multi-user.target
2. Once prompted, enter your administrator password and press Enter to confirm.
3. Reboot your system with:
Step 7: Install Nvidia Drivers
1. Once your system restarts, log in as the root user.
2. Install the Nvidia drivers using the package you downloaded:
In our example, the name is:
bash NVIDIA-Linux-x86_64-390.144.run
3. If prompted, choose the following options during the install process:
- The CC version check failed: Ignore CC version check
- Install NVIDIA’s 32-bit compatibility libraries: Yes
- An incomplete installation of libglvnd was found. Do you want to install a full copy of libglvnd? This will overwrite any existing libglvnd libraries: Install and overwrite existing filesort installation
- Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up: Yes
Step 8: Enable GUI
1. Switching back to the GUI login brings back the option of using a GUI like GNOME and starts up the new Nvidia drivers. Enable the GUI login prompt with:
systemctl set-default graphical.target
2. Reboot your system to finish the installation:
After following this tutorial, you should have Nvidia GPU drivers set up and ready to use with your Debian 10 system.