How To Install NVIDIA Driver in Ubuntu? – Full Guide

If you are a Ubuntu user and have an NVIDIA graphics card, you might be missing out on its full potential without the correct driver. Installing the NVIDIA driver in Ubuntu can significantly improve graphics performance and enable features such as CUDA and OpenCL for machine learning and scientific computing.

In this article, I will walk you through the step-by-step process of installing the NVIDIA driver in Ubuntu. Whether you are a gamer, data scientist, or regular user, this guide will help you get the most out of your NVIDIA graphics card in Ubuntu.

Video Tutorial

How To Check For GPUs Installed On Your PC/Laptop?

Before we dive into the driver installation process, let’s check if the GPU is detected correctly or not. This step is important mostly for laptop users as many laptops use hybrid graphics. Hybrid graphics are basically 2 graphics chips working on the same system. The onboard graphics chip is used for general tasks with better battery life and the dedicated GPU is used for graphics-intensive workloads like gaming.

You can use the hwinfo package to find out info about your GPU. If it is not installed, use the following command to install it.

sudo apt update
sudo apt install hwinfo

After installing hwinfo, use this command to get your GPU info.

hwinfo --gfxcard --short

Example output:

[email protected]:~$ hwinfo --gfxcard --short
graphics card:                                                  
                       nVidia GP107 [GeForce GTX 1050 Ti]
                       Intel VGA compatible controller

Primary display adapter: #12

Or, you can use the lshw command to find out your GPU. Use the following command to get it.

sudo lshw -C display

Example output:

[email protected]:~$ sudo lshw -C display
  *-display                 
       description: VGA compatible controller
       product: GP107 [GeForce GTX 1050 Ti]
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: [email protected]:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:141 memory:c3000000-c3ffffff memory:b0000000-bfffffff memory:c0000000-c1ffffff ioport:3000(size=128) memory:c4000000-c407ffff
  *-display
       description: VGA compatible controller
       product: CometLake-S GT2 [UHD Graphics 630]
       vendor: Intel Corporation
       physical id: 2
       bus info: [email protected]:00:02.0
       logical name: /dev/fb0
       version: 03
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom fb
       configuration: depth=32 driver=i915 latency=0 resolution=1440,900
       resources: irq:140 memory:c2000000-c2ffffff memory:a0000000-afffffff ioport:4000(size=64) memory:c0000-dffff

How To Install NVIDIA GPU Driver In Ubutnu Using A GUI?

Installing the NVIDIA GPU driver is not a headache anymore. Ubuntu has made a simple solution to easily install your NVIDIA GPU driver. You can install the proprietary NVIDIA driver using the “Software & Updates” app. This app can be used for various purposes including managing Software Sources, PPAs, Updates schedules, Additional Drivers, and many more.

Click on Show Applications from the dock and search for “Software & Updates“.

Search For Software & Updates

Open it and go to the Additional Drivers tab. Here you will find all the compatible drivers for your NVIDIA GPU. Select the latest driver and click on Apply Changes.

Software & Updates Additional Drivers Tab

After installing the NVIDIA Driver, click the Restart button to reboot your system.

Restart After Installing Nvidia Driver

Click on Show Application from the dock and you will see the NVIDIA X Server Settings app in the menu.

Nvidia X Server Settings

Open it to access the NVIDIA Settings.

NVIDIA Settings

How To Install NVIDIA GPU Driver In Ubuntu Using The Terminal?

The above GUI method works fine most of the time. But you can also install NVIDIA drivers from the terminal.

First, you need to find out your NVIDIA graphics card and the recommended driver version. Use the following command to do.

ubuntu-drivers devices

Example output:

[email protected]:~$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C82sv000010DEsd000011BFbc03sc00i00
vendor   : NVIDIA Corporation
model    : GP107 [GeForce GTX 1050 Ti]
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-525 - distro non-free recommended
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-470 - distro non-free
driver   : nvidia-driver-515-server - distro non-free
driver   : nvidia-driver-515 - distro non-free
driver   : nvidia-driver-510 - distro non-free
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-525-server - distro non-free
driver   : nvidia-driver-390 - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

Here you can see that the GPU model is GeForce GTX 1050 Ti and the latest driver version is 525. The driver package name is nvidia-driver-525.

Note that, the latest graphics drivers might not work with the older graphics cards. For example, 700 Series graphics cards. If you are having an older card, you may not get the latest driver. Only supported graphics cards can have the latest driver. Use the following command to install the recommended driver.

sudo ubuntu-drivers autoinstall

Or you can also install the driver using the APT Package Manager.

sudo apt install nvidia-driver-525

After installing the GPU driver, reboot your system and your GPU will be up and running. Use the following command to reboot the system.

sudo reboot

How To Install Beta nVidia Drivers Using The PPA Repository?

This PPA Repository lets you install the bleeding edge NVIDIA Beta Drivers. But there is a catch. Though these drivers offer bleeding-edge technology, they are unstable and your system might have some weird issues. It is not recommended but you can use it at your own risk.

Add the NVIDIA PPA Repository using the following command.

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

Identify your NVIDIA graphics card and the recommended driver version by using the following command.

ubuntu-drivers devices

Example output:

[email protected]:~$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C82sv000010DEsd000011BFbc03sc00i00
vendor   : NVIDIA Corporation
model    : GP107 [GeForce GTX 1050 Ti]
driver   : nvidia-driver-510 - distro non-free
driver   : nvidia-driver-515 - distro non-free
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-525 - third-party non-free recommended
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-515-server - distro non-free
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-470 - distro non-free
driver   : nvidia-driver-525-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

Use the following command to install the recommended driver.

sudo ubuntu-drivers autoinstall

Or you can also install the driver using the APT Package Manager.

sudo apt install nvidia-driver-525

After installing the GPU driver, reboot your system and your GPU will be up and running. Use the following command to reboot the system.

sudo reboot

How To Manual Install Official NVIDIA Driver From nvidia.com?

You can manually install the NVIDIA driver package from nvidia.com. Search for your appropriate driver and download the driver package. Or you can visit the NVIDIA drivers archive page to download the package. This method is not recommended as it requires technical knowledge. So, process at your own risk.

After downloading the driver, copy the downloaded file to your Home directory.

Now, install the prerequisites to compile and install the NVIDIA driver.

sudo apt install build-essential libglvnd-dev pkg-config

Now you need to disable the default Nouveau NVIDIA open-source driver.

sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

Use the cat command to verify the newly created modeprobe file “blacklist-nvidia-nouveau.conf“.

cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0

Enter the following command to update kernel initramfs.

sudo update-initramfs -u

Now reboot your system using the following command.

sudo reboot

Now you need to stop the current display server. Enter into runlevel 3 using the following command. Or you can use ctrl+alt+F1 and enter your username and password to start a new TTY1 session.

sudo telinit 3

After login into your user account, use the following command to install the NVIDIA Driver.

sudo bash NVIDIA-Linux-x86_64-525.89.02.run

Follow the instructions to complete the setup. After completing the setup process, reboot your system.

sudo reboot

Your NVIDIA Driver is successfully installed.

How To Verify NVIDIA Driver Installation?

After installing the NVIDIA driver, run this command in the terminal to verify the driver is working.

nvidia-smi

nvidia-smi is a command-line tool you can use to monitor and control NVIDIA Graphics Cards, like Tesla, Quadro, GRID, and GeForce. It can tell you which programs are using your graphics card and how is the temperature to it. You can use nvidia-smi to check which version of the NVIDIA Driver you’re using.

nvidia-smi --query-gpu=driver_version --format=csv

Example output:

[email protected]:~$ nvidia-smi --query-gpu=driver_version --format=csv
driver_version
525.89.02

How To Configure The NVIDIA Graphics Driver?

You can open the NVIDIA X Server Settings panel from the applications menu. Click on Show Applications and search for NVIDIA X Server Settings.

Nvidia X Server Settings

Or you can use the following command in the terminal to start the NVIDIA X Server Settings.

nvidia-settings

Conclusion

I hope you have found this tutorial helpful. You can now install the latest NVIDIA Graphics Drivers in Ubuntu/Linux. If you are still having issues installing NVIDIA Drivers, feel free to comment down below. And if you find this tutorial helpful, share this with your friends who need it.

Leave a Comment

Your email address will not be published. Required fields are marked *

one + seven =