How to Install Nvidia Drivers on Ubuntu 24.04, 22.04 or 20.04

Nvidia Drivers are pivotal in leveraging the full potential of Nvidia GPUs, catering to various computational needs, from gaming to professional graphics work and artificial intelligence research. These drivers ensure seamless integration with the operating system, providing an optimized computing experience through enhanced performance, stability, and compatibility.

Key highlights of Nvidia Drivers include:

  • Enhanced Performance: Unlock superior graphics and computational capabilities, ensuring smooth and efficient processing.
  • Advanced Features: Access to cutting-edge technologies like ray tracing, deep learning super sampling (DLSS), and AI-driven applications.
  • Energy Efficiency: Improved power management for longer battery life and lower energy consumption.
  • Robust Stability: Regular updates and patches ensure compatibility with the latest games and applications.
  • Broad Compatibility: Support a wide range of Nvidia GPUs, from older models to the latest releases.
  • Optimized Graphics: Crisp, clear visuals for gaming, professional graphics work, and video streaming.
  • Customizable Settings: Users can tailor their experience to their performance or quality preferences.
  • Developer Support: Extensive resources and tools for developers to harness the power of Nvidia GPUs in their projects.

Now, let’s install these drivers to ensure your system is fully equipped to meet your graphics and computational demands.

Remove Previous NVIDIA Installations on Ubuntu

If you’ve previously installed NVIDIA drivers using a specific method and wish to reinstall using a different approach mentioned here, be cautious. Mixing multiple NVIDIA repositories can disrupt your drivers. It’s recommended that you revert the Mesa drivers first and then install the NVIDIA drivers.

Note: You can bypass this section if you haven’t installed any NVIDIA drivers yet.

Method 1: APT Method Removal of NVIDIA Drivers

First, use a blanket command to remove any traces of NVIDIA installation on your system. This command searches for any NVIDIA-related packages and purges them from your system:

sudo apt autoremove nvidia* --purge

Method 2: Removing Runfile NVIDIA Driver Installations

Suppose you have installed the NVIDIA drivers using the “.run” file method (which is not recommended due to better alternatives like the NVIDIA CUDA repository). In that case, you need to remove them using a different approach.

To remove the runfile type of installation, use the following command:

sudo /usr/bin/nvidia-uninstall

Method 3: Removing NVIDIA CUDA Toolkit Runfile Installations

If you have installed the CUDA toolkit using the runfile method, you must also remove it. To do so, execute the following command:

sudo /usr/local/cuda-X.Y/bin/cuda-uninstall

Replace X.Y with the version number of your installed CUDA toolkit.

These methods should remove any existing NVIDIA drivers from your Ubuntu system, allowing you to proceed with a fresh installation.

Pre-installation Steps For NVIDIA Drivers Installation

Before installing the NVIDIA drivers, it is essential to perform some pre-installation checks to ensure a smooth installation process. This section will guide you through the necessary steps.

Update Ubuntu Before Nvidia Drivers Installation

Updating your system ensures that all packages are up-to-date, reducing the likelihood of conflicts during the installation. This is particularly important when installing packages such as new kernels and graphics card drivers.

First, update the package list:

sudo apt update

Next, upgrade any outdated packages:

sudo apt upgrade

Determine Your Graphics Card

It is essential to determine if your older NVIDIA graphics card is supported. Users with brand-new cards can skip this step, as they will undoubtedly be supported.

First, find your graphics card module using the following command:

lspci | grep -e VGA

This command will display information about your graphics card. An example output is shown below:

03:00.0 VGA compatible controller: NVIDIA Corporation TU117 [GeForce GTX 1650] (rev a1)

If you use an older card, research it on the NVIDIA website to check if the latest drivers support it. In some cases, you may need to install legacy drivers instead.

Method 1: Install NVIDIA Drivers with Ubuntu Repository via CLI Terminal

The command line is the first option for installing NVIDIA drivers on your Ubuntu system. While advanced users may prefer command-based methods, even beginners can easily follow this approach.

See also
How to Install GNOME Flashback on Ubuntu 22.04 or 20.04

Identify Your Graphics Card and Recommended Driver

Open your terminal by pressing CTRL+ALT+T and find information about your graphics card using the following command:

ubuntu-drivers devices
Display of Ubuntu's default repository with Nvidia drivers for Ubuntu 24.04, 22.04 and 20.04.
Ubuntu default repository listing Nvidia drivers for 24.04, 22.04, and 20.04 versions.

In the example output, the graphics card model is “TU117 [GeForce GTX 1650]”, and the recommended NVIDIA driver is “nvidia-driver-545-open”. Remember that your NVIDIA graphics card model may differ, so look for the recommended driver option in your output.

Install the Recommended Driver or Choose Another Version

You can install the recommended driver package using one of the two methods below.

If you are satisfied with the recommended version, use this command to install it automatically:

sudo ubuntu-drivers autoinstall

If you prefer to install a specific driver version, use the appropriate command from the list below. Remember that these version numbers are examples and will change over time.

The commands below are just common examples. Remember, Nvidia releases newer versions all the time. This guide may not be updated for each command, but it will still exist.

sudo apt install nvidia-driver-550
sudo apt install nvidia-driver-545
sudo apt install nvidia-driver-535
sudo apt install nvidia-driver-530
sudo apt install nvidia-driver-525
sudo apt install nvidia-driver-520
sudo apt install nvidia-driver-515
sudo apt install nvidia-driver-510

Reboot Your System

Once the driver installation is complete, reboot your Ubuntu system by entering the following command:

reboot

After the system restarts, your NVIDIA drivers should be successfully installed and ready for use.

Method 2: Install NVIDIA Drivers with Ubuntu Repository via Desktop GUI

The second solution for installing NVIDIA drivers on your Ubuntu system is using the graphical user interface (GUI) method. This approach is especially recommended for beginners in Linux.

Open “Additional Drivers” Application

First, go to your application menu and open the “Additional Drivers” application. For users new to Ubuntu, you can find it by following these steps:

  1. Click “Activities” in the top-left corner of the screen.
  2. Type “Additional Drivers” in the search bar.
  3. Select the “Additional Drivers” application from the search results.
GUI installation of Nvidia drivers on Ubuntu 24.04, 22.04, or 20.04 through Additional Drivers.
Nvidia drivers installation via the GUI method in Ubuntu Additional Drivers section.

Choose the NVIDIA Driver to Install

The “Software & Updates” window will appear, displaying a list of available drivers for your NVIDIA graphics card. The number of drivers listed may vary depending on the age and popularity of your graphics card.

Select the NVIDIA driver you wish to install and click the “Apply Changes” button. The installation process will take 2 to 3 minutes, depending on your system and its resources.

Selecting and applying Nvidia drivers with a reboot prompt on Ubuntu 24.04, 22.04, or 20.04.
A reboot prompt on Ubuntu follows the selection and application of Nvidia drivers.

Reboot Your System

Once the driver installation is complete, reboot your system. You can do this immediately by typing the following command in your terminal:

reboot

Method 3: Install NVIDIA Drivers using “graphics-drivers/ppa”

The following method involves installing NVIDIA drivers from the graphics-drivers/ppa repository, which is known for providing the most up-to-date proprietary NVIDIA drivers. This approach is recommended for users who want to update their graphics drivers regularly.

Install Required Dependencies

First, you need to install the required dependencies by executing the following command:

sudo apt install software-properties-common -y

Add the graphics-drivers PPA

Next, add the graphics-drivers/ppa repository to your system using the following command:

sudo add-apt-repository ppa:graphics-drivers/ppa -y

Refresh Package Cache

With the PPA now added to your system, update the package list by running:

sudo apt update

Check Recommended Nvidia Drivers

Now, enter the following command to display the recommended drivers for your graphics card:

ubuntu-drivers devices

The output will differ from the one you received using the standard Ubuntu APT repository. In the list, you will see a third-party recommended driver.

Install NVIDIA Drivers via APT Command from the PPA

To install the driver, choose one of the following options:

If you are satisfied with the recommended version, use this command:

sudo ubuntu-drivers autoinstall

Alternatively, if you want to install a specific driver version, use one of the commands below:

sudo apt install nvidia-driver-550
sudo apt install nvidia-driver-545
sudo apt install nvidia-driver-535
sudo apt install nvidia-driver-530
sudo apt install nvidia-driver-525
sudo apt install nvidia-driver-520
sudo apt install nvidia-driver-515
sudo apt install nvidia-driver-510
sudo apt install nvidia-driver-470
sudo apt install nvidia-driver-450
sudo apt install nvidia-driver-390

Reboot Your System

Once the installation is complete, reboot your system using the following command:

reboot

After the restart, the newly installed NVIDIA drivers from the graphics-drivers/ppa repository will be active on your system.

Method 4: Install NVIDIA Drivers on Ubuntu LTS releases via CUDA PPA

This section only applies to Ubuntu 24.04, 22.04, and 20.04 LTS releases. Short-term releases cannot use this method.

See also
How to Setup Nginx FastCGI Cache on Ubuntu 24.04, 22.04 or 20.04

Install the Required Packages To Install Nvidia Drivers from CUDA PPA

The last method of installing NVIDIA drivers involves using the NVIDIA CUDA repository, which is frequently updated and supports Debian, Ubuntu, RHEL, and other popular Linux distributions.

First, make sure to install the following packages, which might already be installed on your system:

sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https dkms curl -y

Import NVIDIA Repository GPG Key on Ubuntu

Next, import the GPG key for your distribution version:

Noble Numbat: Ubuntu 24.04:

curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1

Jammy Jellyfish: Ubuntu 22.04:

curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1

Focal Fossa: Ubuntu 20.04:

curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1

Add NVIDIA CUDA Repository

Now, add the NVIDIA repository for your system, ensuring you import the correct one to match your Ubuntu distribution version:

Noble Numbat: Ubuntu 24.04:

echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list

Jammy Jellyfish: Ubuntu 22.04:

echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list

Focal Fossa: Ubuntu 20.04:

echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list

Refresh APT Package Index

Update your sources list to reflect the newly added repository:

sudo apt update

Search and Install Nvidia Drivers VIA Nvidia PPA

Next, install the latest Nvidia drivers. You can use the APT search command to view the complete list of available drivers:

apt search nvidia-driver-*

This tutorial demonstrates how to install the latest version currently available. Replace 545 with 530, 525, 520, 515, etc., depending on your preference.

For the best compatibility, install the proprietary version, especially if you are new to Ubuntu. Open-source drivers may cause issues with certain graphics cards.

Advanced users can easily switch between open-source and proprietary drivers as needed.

  • Install NVIDIA Drivers 550.xx without CUDA support (proprietary):
sudo apt install nvidia-driver-550
  • Install NVIDIA Drivers 550.xx with CUDA support (proprietary):
sudo apt install nvidia-driver-550 cuda-drivers-550 cuda
  • Install NVIDIA Drivers 550.xx without CUDA support (open-source):
sudo apt install nvidia-driver-550-open
  • Install NVIDIA Drivers 550.xx with CUDA support (open-source):
sudo apt install nvidia-driver-550-open cuda-drivers-550 cuda

If the above drivers do not work, try using version 545, 530, 520, 515, etc., or use the search command mentioned earlier to find other versions.

Install Nvidia Headless Drivers

Installing NVIDIA drivers directly from the CUDA repository for non-desktop users and those running servers with specialized software is often best. The instructions are the same as for desktop users, but you need to add “headless” to the command.

Proprietary NVIDIA 545 headless drivers

sudo apt install nvidia-headless-545

Open-source NVIDIA 545 headless drivers

sudo apt install nvidia-headless-545-open

For more options, use the APT search command in your terminal to locate specific packages:

apt search nvidia-headless*

Additionally, you can add CUDA and any other required packages. Desktop users should not install headless drivers.

Confirming Nvidia Drivers Installation

Once you have successfully installed the Nvidia drivers and rebooted your system, verifying that the installation was successful is essential. This section will guide you in confirming the installation using the command line and the graphical user interface (GUI).

Check Nvidia Drivers via Terminal

You can use the command to verify the installation through the command line. This command will display information about your Nvidia GPU, such as the driver version, GPU usage, temperature, and more.

nvidia-smi
'nvidia-smi' command output showing Nvidia drivers installed on Ubuntu 24.04, 22.04, or 20.04.
Output of ‘nvidia-smi’ command confirming Nvidia drivers installation on Ubuntu.

Access Nvidia Settings GUI

You can launch the Nvidia settings GUI if you prefer a graphical interface. To do this, follow the steps below:

Open the terminal and enter the following command:

nvidia-settings

Alternatively, you can access the Nvidia settings through the application menu:

Go to Activities > Show Applications > NVIDIA X Server Settings.

Nvidia X Server Settings interface on Ubuntu 24.04, 22.04, or 20.04 for driver management.
Exploring Nvidia X Server Settings for driver management on Ubuntu.

After opening the Nvidia settings GUI, you can see your GPU’s configuration, information, and other settings that can be customized.

Accessing Nvidia X Server Settings GUI on Ubuntu 24.04, 22.04, or 20.04 for advanced configurations.
Nvidia X Server Settings GUI for detailed driver configurations on Ubuntu.

Conclusion

In wrapping up, this guide walked you through installing Nvidia Drivers on Ubuntu 24.04, 22.04, or 20.04 LTS, showing you the ropes with a few straightforward methods. Remember, keeping your drivers updated ensures your Nvidia GPU runs smoothly, giving you the best performance for whatever you’re tackling, be it work, gaming, or creative projects. Don’t hesitate to revisit these steps or check for updates to keep things running optimally.

Useful Links

Here are some useful links related to installing NVIDIA drivers on Ubuntu Linux:

  • Graphics Drivers PPA: Access the latest NVIDIA drivers from the Ubuntu graphics drivers PPA. This repository often has the most up-to-date drivers available.
  • NVIDIA Unix Drivers: Visit NVIDIA’s official page for Unix drivers to download the latest drivers directly from NVIDIA.
  • NVIDIA CUDA Toolkit: Learn about and download the CUDA Toolkit, which includes drivers and tools for GPU-accelerated computing.
  • NVIDIA Tesla Driver Documentation: Read the documentation for NVIDIA Tesla drivers, providing detailed information on driver branches and updates.
  • NVIDIA Forums: Join the NVIDIA community forums to discuss issues, share solutions, and get support from other NVIDIA users.
See also
How to Install PHP 8.2 on Ubuntu 22.04 or 20.04

These links provide additional information and resources to help you install and manage NVIDIA drivers on your Ubuntu system.

3 thoughts on “How to Install Nvidia Drivers on Ubuntu 24.04, 22.04 or 20.04”

  1. Just as a heads-up after rebooting I could not get to nvidia-smi so I did (DO NOT ENTER THIS COMMAND YET) sudo prime-select nvidia. And after rebooting again I couldn’t use my mouse or keyboard, found a solution here:
    https://forums.developer.nvidia.com/t/ubuntu-22-04-2-lts-nvidia-525-105-17-hangs-on-login-screen/249679

    Which basically is doing: sudo apt-get install xserver-xorg-input-all
    Then do “sudo prime-select nvidia” and reboot

    NOTE: If after reboot your mouse and keyboard are not responding enter in recovery mode (select to open a shell) and switch back to intel “sudo prime-select nvidia” then do the steps above.

    Reply

Leave a Comment


TOC Index
Your Mastodon Instance
Share to...