Steps to Install Nvidia Drivers on Ubuntu [3 Methods]


Written By - Omer Cakmak
Advertisement

Ubuntu is a popular Linux-based operating system widely used in many fields, including data science, machine learning, and gaming. Nvidia graphics cards are among the most popular options for high-performance computing and gaming, but Ubuntu users may face issues when it comes to installing and configuring the Nvidia drivers for their systems.

Installing Nvidia drivers on Ubuntu can be a daunting task, especially for users with little experience in Linux system administration. However, with the right guidance and a few simple steps, installing Nvidia drivers on Ubuntu can be done quickly and easily.

In this guide, we will walk you through the steps required to install the Nvidia drivers on Ubuntu, including downloading and installing the appropriate drivers, configuring the X server, and troubleshooting common issues that may arise during the process. Whether you are a data scientist, a gamer, or a regular Ubuntu user, this guide will help you get the most out of your Nvidia graphics card.

 

Pre-requisites

Check your hardware:

Nvidia drivers require a compatible Nvidia graphics card to function properly. Make sure that your system has an Nvidia graphics card installed and that it is compatible with the version of the Nvidia driver that you plan to install.

To check if your Ubuntu system has an Nvidia graphics card installed and verify if it is compatible with the Nvidia driver, you can use the following command in the terminal:

lspci -vnn | grep VGA

OR

lspci -nn | grep '\[03'

This command will display information about the graphics card installed on your system, including the vendor and model of the graphics card. If the output includes the name "NVIDIA Corporation," it indicates that your system has an Nvidia graphics card.

Advertisement

To check the compatibility of your Nvidia graphics card with the Nvidia driver, you can refer to the Nvidia documentation or use the following command to check the recommended driver version for your graphics card:

ubuntu-drivers devices

This command will display a list of available drivers for your system, including the recommended Nvidia driver for your graphics card.

 

Disable Nouveau driver:

Ubuntu comes with a default open-source driver called "Nouveau" that may conflict with the Nvidia driver. To avoid any conflicts, it is recommended that you disable the Nouveau driver by adding the following lines to the "/etc/modprobe.d/blacklist-nouveau.conf" file:

blacklist nouveau
options nouveau modeset=0

 

Update your system:

Before installing the Nvidia driver, it is recommended that you update your Ubuntu system to ensure that you have the latest packages and security updates. You can do this by running the following command:

sudo apt-get update && sudo apt-get upgrade

 

 

Different methods to install Nvidia driver on Ubuntu

There are 3 different methods to install Nvidia drivers on Ubuntu. With each of these methods, you can do a hassle-free installation. Let's explain in order.

 

Method-1: Install from Repository

The Ubuntu version you are using has the Nvidia driver in the repositories. To see what versions exist:

$ sudo apt search "NVIDIA driver metapackage"
Sorting... Done
Full Text Search... Done
mir-graphics-drivers-nvidia/jammy 2.7.0-0ubuntu3 amd64
  Display server for Ubuntu - Nvidia driver metapackage

nvidia-driver-390/jammy-updates,jammy-security 390.157-0ubuntu0.22.04.1 amd64
  NVIDIA driver metapackage

nvidia-driver-470/jammy-updates,jammy-security 470.161.03-0ubuntu0.22.04.1 amd64
  NVIDIA driver metapackage

nvidia-driver-510/jammy-updates,jammy-security 510.108.03-0ubuntu0.22.04.1 amd64
  NVIDIA driver metapackage

nvidia-driver-515/jammy-updates,jammy-security 515.86.01-0ubuntu0.22.04.1 amd64
  NVIDIA driver metapackage

nvidia-driver-525/jammy-updates,jammy-security 525.78.01-0ubuntu0.22.04.1 amd64
  NVIDIA driver metapackage

Update the package list before starting the installation:

sudo apt update -y

Then install the Nvidia driver version you want to install by typing:

$ sudo apt install nvidia-driver-525 -y

nvidia-driver-525 - 525.78.01-0ubuntu0.22.04.1 installation completed.

 

Method-2: Install with Nvidia PPA

You can install Nvidia driver from different repositories. First add the repository to the system:

$ sudo add-apt-repository ppa:graphics-drivers
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'deb https://ppa.launchpadcontent.net/graphics-drivers/ppa/ubuntu/ jammy main'
Description:
Fresh drivers from upstream, currently shipping Nvidia.
...
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
...

Then update the package list:

$ sudo apt update -y

And start the installation of the latest version:

$ sudo apt install nvidia-driver-525 -y

The nvidia/525.89.02 package installation has been completed successfully.

 

Method-3: Install with .run File

In this method, we will install the driver shared from Nvidia's official site on Ubuntu. First, pull the .run setup file with wget:

$ wget https://us.download.nvidia.com/XFree86/Linux-x86_64/525.89.02/NVIDIA-Linux-x86_64-525.89.02.run
--2023-03-15 21:06:52--  https://us.download.nvidia.com/XFree86/Linux-x86_64/525.89.02/NVIDIA-Linux-x86_64-525.89.02.run
Resolving us.download.nvidia.com (us.download.nvidia.com)... 192.229.221.58, 2606:2800:233:ef6:15dd:1ece:1d50:1e1
Connecting to us.download.nvidia.com (us.download.nvidia.com)|192.229.221.58|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 414116295 (395M) [application/octet-stream]
Saving to: ‘NVIDIA-Linux-x86_64-525.89.02.run’

NVIDIA-Linux-x86_ 100%[=============>] 394,93M  3,18MB/s    in 2m 27s  

2023-03-15 21:09:20 (2,68 MB/s) - ‘NVIDIA-Linux-x86_64-525.89.02.run’ saved [414116295/414116295]

Then run this file as follows:

foc@ubuntu22desktop:~$ sudo sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 525.89.02...........
.....

Follow the on-screen instructions during installation and complete the installation.

Steps to Install Nvidia Drivers on Ubuntu [3 Methods]

Restart your computer for the new driver to take effect:

sudo reboot

 

Check Installed Nvidia Driver Status

To check the driver status:

$ nvidia-smi
Fri Mar 17 16:03:35 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.86.01    Driver Version: 515.86.01    CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla V100-SXM2...  On   | 00000000:06:00.0 Off |                    0 |
| N/A   30C    P0    57W / 300W |   8854MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  Tesla V100-SXM2...  On   | 00000000:07:00.0 Off |                    0 |
| N/A   44C    P0    73W / 300W |  28060MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   2  Tesla V100-SXM2...  On   | 00000000:0A:00.0 Off |                    0 |
| N/A   47C    P0   227W / 300W |  25648MiB / 32768MiB |     79%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   3  Tesla V100-SXM2...  On   | 00000000:0B:00.0 Off |                    0 |
| N/A   28C    P0    41W / 300W |      3MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   4  Tesla V100-SXM2...  On   | 00000000:85:00.0 Off |                    0 |
| N/A   29C    P0    40W / 300W |      3MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   5  Tesla V100-SXM2...  On   | 00000000:86:00.0 Off |                    0 |
| N/A   31C    P0    56W / 300W |  28058MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   6  Tesla V100-SXM2...  On   | 00000000:89:00.0 Off |                    0 |
| N/A   32C    P0    41W / 300W |      5MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   7  Tesla V100-SXM2...  On   | 00000000:8A:00.0 Off |                    0 |
| N/A   29C    P0    42W / 300W |      3MiB / 32768MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A   3361223      C   /opt/conda/bin/python            8843MiB |
|    1   N/A  N/A   2288532      C   python                          28057MiB |
|    2   N/A  N/A    915081      C   python                          25645MiB |
+-----------------------------------------------------------------------------+

To find out if Nvidia drivers are installed on your Linux machine:

lspci | grep -i nvidia

You can run the following command to see the list of Nvidia drivers installed on the system:

$ dkms status
nvidia/525.89.02, 5.19.0-35-generic, x86_64: installed

 

Remove Nvidia Driver

To remove the Nvidia packages installed in 3 steps above, simply run the following command in the terminal:

$ sudo apt purge nvidia-driver-525 -y

Then the following command removes the dependencies that come with the Nvidia driver package:

$ sudo apt autoremove -y

You are now ready for a new installation.

 

Troubleshooting common issues

During the installation of Nvidia drivers on Ubuntu, you may encounter some common issues that can cause problems with the installation or the performance of your system. Here are a few tips for troubleshooting these issues:

  1. Black screen on boot: If your system displays a black screen on boot after installing Nvidia drivers, try adding the "nomodeset" parameter to your boot options. This can be done by editing the "grub" configuration file located in the "/etc/default" directory.
  2. Low resolution or no 3D acceleration: If you experience low resolution or no 3D acceleration after installing Nvidia drivers, try running the "nvidia-settings" command and configuring the display settings from there. You may also need to install additional packages, such as "nvidia-cuda-toolkit", to enable 3D acceleration.
  3. Driver conflicts: If you have previously installed other graphics drivers on your system, you may encounter conflicts when installing Nvidia drivers. To resolve this issue, remove any existing graphics drivers and dependencies before installing the Nvidia drivers.

By following these tips and taking the time to properly configure your system, you can ensure a smooth and trouble-free installation of Nvidia drivers on Ubuntu.

 

Summary

In the article, three methods have been explained for installing Nvidia drivers on Ubuntu. The first method involves installing the Nvidia driver from the official Ubuntu repository. The second method is to install the Nvidia driver using the Nvidia PPA (Personal Package Archive) repository. The third method involves installing the Nvidia driver using the .run file downloaded from the Nvidia website.

The article provides step-by-step instructions for each method, along with tips for troubleshooting common issues that may arise during the installation process.

You can see the latest Nvidia driver versions from the official page.

 

References

askubuntu.com - How do I install the Nvidia drivers?
docs.nvidia.com - Runfile Installers

 

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment