Installing NVIDIA drivers on Ubuntu is crucial for users who want to optimize their system’s performance, especially for gaming, 3D rendering, or CUDA-based computations. Ubuntu offers several methods to install these drivers, depending on your needs and preferences. You can use the Ubuntu default repository for a straightforward installation, the ppa:graphics-drivers/ppa Launchpad PPA for access to the latest drivers, or the NVIDIA CUDA APT repository for those specifically working with CUDA development.
This guide will walk you through the installation process using each of these methods on Ubuntu 24.04, 22.04, or 20.04, ensuring that you have the right driver setup for your hardware and use case.
Remove Previous NVIDIA Installations
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. You should 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 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.
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
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 constantly releases newer versions. 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 via Desktop GUI
The second solution for installing NVIDIA drivers on your Ubuntu system is using a graphical user interface (GUI). This approach is especially recommended for Linux beginners.
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:
- Click “Activities” in the top-left corner of the screen.
- Type “Additional Drivers” in the search bar.
- Select the “Additional Drivers” application from the search results.
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. Depending on your system and its resources, the installation process will take 2 to 3 minutes.
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 LTS releases via CUDA PPA
This section only applies to Ubuntu 24.04, 22.04, and 20.04 LTS releases. It cannot be used for short-term releases.
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
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. If you prefer, replace 545 with 530, 525, 520, 515, etc.
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 earlier search command to find other versions.
Install Nvidia Headless Drivers
For non-desktop users and those running servers with specialized software, installing NVIDIA drivers directly from the CUDA repository 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 line to verify the installation. This command will display information about your Nvidia GPU, such as the driver version, GPU usage, temperature, and more.
nvidia-smi
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.
After opening the Nvidia settings GUI, you can see your GPU’s configuration, information, and other settings that can be customized.
Conclusion
By installing NVIDIA drivers using the method that best suits your needs, you can ensure optimal performance and compatibility with your Ubuntu system. Whether you choose the stability of the Ubuntu default repository, the cutting-edge drivers from the ppa:graphics-drivers/ppa, or the CUDA-optimized drivers from the NVIDIA CUDA repository, each method provides a reliable way to keep your GPU running efficiently. While updates to these drivers are common, be sure to select the repository that aligns with your specific requirements to maintain a smooth and stable experience on your Ubuntu system.
Useful Links
Here are some helpful links related to installing NVIDIA drivers:
- 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.
I tried method 3, the ppa, and got errors installing nvidia-driver-390 for a Geforce GT 730. This left me with a system that no longer boots.
May I ask which Ubuntu release you ran into troubles installing the Nvidia Drivers on?
Great job!!! It worked perfectly with my Asus Tuf 15 gaming laptop (rtx 3050 inside)
Great tutorial, tysm!
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.