2 Ways to Install Nvidia Driver on Ubuntu 22.04/20.04 (GUI & Command Line)

This tutorial will be showing you 2 ways to install Nvidia graphics card driver on Ubuntu 22.04/20.04. The first method uses graphical user interface (GUI); The second method is done from the command-line interface (CLI). Ubuntu comes with the open-source nouveau driver which is included in the Linux kernel for Nvidia cards.  However, this driver lacks 3D acceleration support. If you are a gamer or need to work with 3D graphics, then you will benefit from the better performance of the proprietary Nvidia driver.

Note: Before installing the proprietary driver, I recommend disabling secure boot if you are using UEFI firmware. If secure boot is enabled, you might encounter problems after installing Nvidia driver. This tutorial also assumes that you are running Ubuntu 22.04/20.04 with x.org display server.

This tutorial also works for Linux Mint.

How to Install Nvidia Graphics Driver on Ubuntu 22.04/20.04 From Graphical User Interface

First, go to SettingsAbout and check what graphics card your computer is using. As you can see, my computer is using Nvidia graphics card and the Nouveau driver (NV132). On some computers, the integrated graphics card (Intel HD Graphics) might be used.

ubuntu nouveau driver

Then open the softare & updates program from your application menu. Click the additional drivers tab. You can see what driver is being used for Nvidia card (Nouveau by default) and a list of proprietary drivers.

ubuntu nvidia driver

As you can see, the following Nvidia drivers are available for my GeForce GTX 1080 Ti card.

  • nvidia-driver-470 (tested)
  • nvidia-driver-460
  • nvidia-driver-495

If you read this article at a later time, you might have newer version of Nvidia drivers. Since nvidia-driver-470 is a tested version, so I select the first option to install nvidia-driver-470.  Click the Apply Changes button to install the driver.

install-nvidia-driver-ubuntu-20.04-LTS

After it’s installed, reboot your computer for the change to take effect. After that, go to Settings > About, you will see Ubuntu is using Nvidia graphics card.

ubuntu NVIDIA Corporation GP102 GeForce GTX 1080 Ti

If you want Ubuntu to use Intel graphics card, open Nvidia X Server Settings from the application menu. Click PRIME Profiles tab on the left pane, and then select Intel card on the right pane.

ubuntu 18.04 nvidia prime profile

To switch back to Nvidia card, simply select NVIDIA in PRIME Profiles. In the Thermal Settings, you can check your GPU temperature.

How to Install Nvidia Driver on Ubuntu 22.04/20.04 From the Command Line

First, open up a terminal window and check which driver is being used for Nvidia card with the following command.

sudo lshw -c display

You can also use video instead of display as the class name.

sudo lshw -c video

By default, the open-source nouveau driver is being used for Nvidia card.

nvidia driver ubuntu 18.04

Next, run the following command to list available drivers for your Nvidia card from the default Ubuntu repository.

sudo ubuntu-drivers devices

sudo ubuntu-drivers devices

As you can see, there are 3 drivers available for my GeForce GTX 1080 Ti card.

  • nvidia-driver-470 (recommended)
  • nvidia-driver-390
  • nvidia-driver-460
  • nvidia-driver-495
  • xserver-xorg-video-nouveau

If you read this article at a later time, you might have newer versions of Nvidia driver. To install the recommended driver, run the following command.

sudo ubuntu-drivers autoinstall

ubuntu sudo nvidia-drivers autoinstall

This will install some 32-bit packages as indicated by the i386 suffix. If you want to install a particular driver, run the following command.

sudo apt install nvidia-driver-version-number

For example:

sudo apt install nvidia-driver-495

After the driver is installed, we need to run the following command to reboot the computer, in order to enable nvidia-prime, which is technology to switch between Intel and Nvidia graphics cards.

sudo shutdown -r now

Now the proprietary Nvidia driver is being used.

sudo lshw -c display

ubuntu proprietary Nvidia driver

You can check which card is being used now with the following command:

prime-select query

ubuntu nvidia prime

If you want to use Intel graphics card, run the following command:

sudo prime-select intel

To switch back to Nvidia card, run

sudo prime-select nvidia

Notice that you may need a reboot for the change to take effect.

Install the Latest Version Of Nvidia Drivers via PPA

Update: Canonical now includes the latest version of Nvidia drivers in Ubuntu LTS repository. The information in this section is for archive purpose only. You can ignore it.

Nvidia website maintains a page for its latest driver for Unix/Linux platforms. On this page, you can see the latest version of Nvidia drivers. At the time of this writing, the latest version is 430.40. Clicking the version number will take you to a page where you can see changelogs and whether your card is supported or not.

Unix Drivers NVIDIA archive

The driver included in the default Ubuntu repository can be outdated but more stable. If you would like to install the latest version, you can add a PPA maintained by Ubuntu Team.

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

Notice that you don’t need to manually run sudo apt update after adding PPA on Ubuntu 22.04/20.04. This operation becomes automatic on Ubuntu 22.04/20.04. Now you can run:

sudo ubuntu-drivers devices

The newest version becomes the recommended driver.

ubuntu nvidia driver ppa

Now you can run the following command to install the newest version.

sudo ubuntu-drivers autoinstall

This PPA is still considered testing. Sometimes you might encounter dependency problems like below.

ubuntu 18.04 nvidia driver ppa

If you prefer stability over bleeding-edge, you can quit installing it. But if you are willing to take risks, you can upgrade the libraries by running the following command.

sudo apt upgrade

Then re-run the install command.

sudo ubuntu-drivers autoinstall

If there are still dependency problems, you can manually install them. For example, I saw the following error message.

The following packages have unmet dependencies:
 nvidia-driver-396 : Depends: xserver-xorg-video-nvidia-396 (= 396.24.02-0ubuntu0~gpu22.04/20.04.1) but it is not going to be installed
                     Depends: libnvidia-cfg1-396 (= 396.24.02-0ubuntu0~gpu22.04/20.04.1) but it is not going to be installed

I ran this command to fix the issue.

sudo apt install libnvidia-cfg1-396 xserver-xorg-video-nvidia-396 nvidia-driver-396

Once the newest version is installed, reboot your computer.

sudo shutdown -r now

Help Files

You can find the help files by running the following command.

dpkg -L nvidia-driver-390

Replace 390 with your driver version number.

How to Automatically Update Nvidia Driver

It’s important to keep the Nvidia driver up to date. If you use an outdated driver or the open-source nouveau driver, then your desktop environment (like GNOME) might become sluggish and your CPU usage is very high. I once had the gnome-shell process consuming 30% of CPU.

To update Nvidia driver, simply run sudo ubuntu-drivers install command. You can automate it by creating a systemd service with the Nano command-line text editor.

sudo nano /etc/systemd/system/update-nvidia.service

Add the following lines in this file.

[Unit]
Description= Update Nvidia Driver
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ubuntu-drivers install

[Install]
WantedBy=multi-user.target

ubuntu Update Nvidia Driver

In the Nano text editor, press Ctrl+O and Enter to save this file. Then press Ctrl+X to exit.  Next, run the following command, so this systemd service will automatically start at boot time.

sudo systemctl enable update-nvidia.service

Can’t Change Screen Resolution?

If you find your screen resolution automatically changed to 1024 x 768, but you can’t set it to a higher resolution, that might be an indicator your Nvidia driver is outdated. You should install the latest version of Nvidia driver, then reboot your system. Also, be sure to update the Linux kernel to the latest available in the software repository.

How to Uninstall the Proprietary Nvidia Driver on Ubuntu 22.04/20.04

If for some reason you don’t want the proprietary driver anymore, you can remove it by running the following command.

sudo apt purge nvidia-*

sudo apt autoremove

To remove Nvidia driver PPA, run:

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

I hope this tutorial helped you install Nvidia driver on Ubuntu 22.04/20.04 desktop, either from GUI or from the command line. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care.

Rate this tutorial
[Total: 170 Average: 4.6]

31 Responses to “2 Ways to Install Nvidia Driver on Ubuntu 22.04/20.04 (GUI & Command Line)

  • Hi,

    Thanks for this tutorial, can I ask, is it possible to switch the graphics cards without rebooting.

    So if I have gimp running using the Intel card, but then I want to run Davinci Resolve for 3D work,
    do I need to switch cards and reboot, or can I set a profile that opens Davinci Resolve using the Nvida drivers?

    Also I’m assuming this would be fairly similar if running CentOS.

    Thanks in advance,

    • Gert Kruger
      5 years ago

      I have a NVIDIA Corporation GP107 [GeForce GTX 1050] card and ubuntu 19.04 installed (18.10 gave the same issue). I tried many proposed solutions, including the one above. Nothing worked.

      I finally found a solution for this Nvidia driver issue (on ubuntu 18 and 19). See instructions at the top at https://ubuntuforums.org/showthread…nvidia+drivers, it worked for me!

  • Christopher
    1 month ago

    Thank you very much for this clear method how to set Nvidia. I really appreciate your effort. For nabs like is essential to get this kind of support you are doing. This and many other things make me glad for dumping the Windows out of the windows.
    With regards Christopher

  • Nice, thank you! I had an issue running nvidia caused by my intel config being in /etc/X11/xorg.conf.d. After I deleted it everything work like a charm

  • Doug D.
    6 days ago

    Hello, My disks are encrypted. I used the graphical user interface to install a new driver. I did not disable secure boot as I now see you had suggested. Now, I cannot unlock my startup drive when I restart the machine. Do you have any suggestions for reverting back to the old driver? I am using a Nvidia K620. Thank you.

    • Xiao Guoan (Admin)
      4 months ago

      You can disable secure boot now, or choose to boot the previous kernel in the Grub boot menu.

  • Hi, It’s a bit old post but maybe you can help.
    I did as you describe but in details the system still tells me I’m using the intel card even if prime-select query tells me I’m set for nvidia.
    Furthermore my lshw -c display keeps saying my system uses nouveau instead of the nvidia driver (even if I set nouveau as blacklist in modprobe.d)
    Any idea?

    • Xiao Guo-An (Admin)
      4 weeks ago

      Nouveau is blacklisted automatically if you install and enable the Nvidia proprietary driver, as can be seen in the file /etc/modprobe.d/nvidia-graphics-drivers.conf.

      blacklist nouveau
      blacklist lbm-nouveau
      alias nouveau off
      alias lbm-nouveau off
      

      Maybe you need to restart your computer to see the changes.

  • Hey,
    thanks for the tutorial, however it doesnt quite work for me. So after

     sudo ubuntu-drivers autoinstall 

    I get stuck with the same depencies missing set of errors and upgrading through

     sudo apt upgrade 

    or manually installing the missing dependencies didn’t really help and I couldn’t get past that point.
    any suggestion as to what to do next ?

    cheers

    • Hi Abmo,

      Is this the issue you encountered?

      The following packages have unmet dependencies.
      nvidia-304 : Depends: xorg-video-abi-11 but it is not installable or
      xorg-video-abi-12 but it is not installable or
      xorg-video-abi-13 but it is not installable or
      xorg-video-abi-14 but it is not installable or
      xorg-video-abi-15 but it is not installable or
      xorg-video-abi-18 but it is not installable or
      xorg-video-abi-19 but it is not installable or
      xorg-video-abi-20 but it is not installable or
      xorg-video-abi-23
      Depends: xserver-xorg-core
      E: Unable to correct problems, you have held broken packages.

      Did you find a solution?

      Thanks.

      -Dan

      • Vance Ayres
        5 years ago

        Dan, did you find a solution for your problem? I have the exact same problem with an old GeForce 7300 LE trying to use 304.137.
        Thanks!
        Vance

  • I had problems, this is how I fixed it for me:
    https://ubuntuforums.org/showthread.php?t=2402524&p=13805074

  • I desperately needed the UNinstall via commandline help found here to recover my machine after enabling the nvidia driver resulted in a black screen after login… thanks for including methods usable at the recovery console!

    • I have had to install Nvidia drivers a 3rd way many many times. Install build-essentials (apt-get install build-essentials). Download latest linux driver from Nvidia.com and extract the file. If you plan on using steam- install that next before proceeding. example: apt-get install steam . Reboot into grub recovery (hold shift key during boot). If you get that far choose–>enable networking (because it changes your drive from read only to read/write, or you can drop to root shell and do it manually. Go to the directory where the nvidia driver that you downloaded and type ./name_of_nvida_file.run

      With your blank screen it can be fixed by adding nomodeset into the grub file located in /etc/default
      nano /etc/default/grub
      Look for GRUB_CMDLINE_LINUX_DEFAULT= and add nomodeset between the ” “.
      Your line might look like this GRUB_CMDLINE_LINUX_DEFAULT=”quiet nomodeset”

      Make sure to run update-grub from command line before rebooting.

  • Excellent tutorial. Very thorough.

  • Hi –
    Any way to make Nvida GeForce 1050 Ti to run my 4K attached monitor at 60Hz instead of 30Hz? Using the latest stable Nvida driver on Ubuntu 18.04.
    Thanks!

  • Iqbal Ahmad
    5 years ago

    Thank you so much for such a complete guide, fortunately this configuration works very well with Ubuntu 18.04/18.10 but doesn’t work on Ubuntu 19.04.
    Couple of times i repeated these steps, installed and uninstall and repeated but it isn’t working.
    Please Help me sort it out.

    Thanks

  • MatthieuBalondrade
    5 years ago

    Hey guys,

    you should also mention for those who use secure boot that when you reboot after a driver has been installed, you will enter a blue screen for secure boot EFI and don’t click on “reboot” directly but on “Register MOK” and enter the password that you had to give during driver installation.

    If not you’ll see nvidia driver installed but not working because it’s a third party driver not registered in secure boot, ubuntu will not pick your nvidia card and still run the Graphic integrated (in my case Intel haswell mobile 4th gen).

  • fernandus
    5 years ago

    Hi,

    I have GTX 1650 and I did installed by GUI, After restarting I cant find GeForce in settings details. On checking NVIDIA X server settings under prime profile I can see NVIDIA performance mode enable.

    So I tried by Command Line after reboot I did lshw -c display under configuration I cant see the driver=nvidia

    this is my first installation dont know that i am using my NVIDIA Graphics.

  • Works great with Ubuntu 18.04 and Nvidia Quadro NVS 450.
    Thank you!

  • andrew grassetti
    4 years ago

    Very helpful comment!

  • Anurag Priyadarshi
    4 years ago

    Nice post! Helped me in fixing my bug on AWS.
    “NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver”

  • Thanks so much for this writeup. I followed the CLI instructions to setup my Nvidia Quadro P2200 graphics card on Ubuntu 18.04 running in an ESXi VM. Question: in the future, if there is a new Nvidia graphics driver, how do we install the new driver? Do I just rerun the following commands?:

    sudo ubuntu-drivers devices

    sudo ubuntu-drivers nvidia-driver-

  • Hi,

    Thank you so much this really helped and was frying my brain for the last few days. I used the guide to manually install the drivers and opted to install all on the list as apposed to specific driver.

    I have seen other ways of doing this on YouTube all appear to be complicated.

    There was one version was in the process of following, which have helped initially was to purge all NVidia drivers beforehand. I then did a ‘nomodeset’ test but then my screen weren’t going blank/black so I decided not to make it permanent as you can do an initial test to see if it works after reboot and then make it permanent.

    This guide is the most simplest and easiest way of doing it.

    Thank you.

  • Thanks you help me to solve this issue

  • Elleshar
    4 years ago

    Gotting a black screen everytime after select boot.

    Happened after


    After the driver is installed, we need to run the following command to reboot the computer, in order to enable nvidia-prime, which is technology to switch between Intel and Nvidia graphics card.

    sudo shutdown -r now

    What can i do all normaly things don’t work linke nomodeset and so on.

    And i got a full black screen, can’t open a terminal and also can’t increase brightness.

    pls help

  • thank you bro! It’s the clearest blog about install nvidia driver on ubuntu!

  • no nvidia 340 on ubuntu 21.04

  • CharaD7
    2 years ago

    This is by far the only tutorial tip that has benefited me so much in configuring my display driver and making it work for external displays. Thanks a bunch NERD

  • Plafundum
    6 months ago

    Hello Linux babe.

    I am running Linux on an iMac 2012, wanted to get 2nd monitor working, killed nvidia and saved it thanks to this one. Thanks!!!!

    https://askubuntu.com/questions/1502439/ubuntu-22-04-on-imac-2012-27-external-screen-not-detected-nvidia

  • Plafundum
    6 months ago

    Here a pic:

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here