2 Ways to Install Nvidia Driver on Ubuntu 18.04 (GUI & Command Line)

This tutorial will be showing you 2 ways to install Nvidia graphics card driver on Ubuntu 18.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 18.04 with x.org display server.

How to Install Nvidia Graphics Driver on Ubuntu 18.04 From Graphical User Interface

First, go to system settings > details and check what graphics card your computer is using. By default, your integrated graphics card (Intel HD Graphics) is being used.

ubuntu 18.04 nvidia 390 driver

Then open softare & updates program from you 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 18.04 nvidia issues

As you can see nvidia-driver-390 is available from my GeForce GTX 1080 Ti card. So I select the first option to install nvidia-driver-390. Your mileage may vary. There might be some other drivers for your particular card. Click Apply Changes button to install the driver.

install nvidia driver on ubuntu 18.04

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

nvidia driver ubuntu 18

If you want Ubuntu to use Intel graphics card, open Nvidia X Server Settings from 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.

How to Install Nvidia Driver on Ubuntu 18.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 driver for your Nvidia card from the default Ubuntu repository.

sudo ubuntu-drivers devices

ubuntu 18.04 nvidia drivers

As you can see, there are only two drivers available for my GeForce GTX 1080 Ti card. One is the proprietary (non-free) driver, which is recommend by Ubuntu. The other is the default open-source Nouveau driver. There may be some other drivers for your Nvidia card. To install the recommended driver, run the following command.

sudo ubuntu-drivers autoinstall

ubuntu 18.04 nvidia drivers not working

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-390

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

sudo shutdown -r now

Now the proprietary Nvidia driver is being used.

sudo lshw -c display

ubuntu 18.04 nvidia 390

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

prime-select query

ubuntu 18.04 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 reboot for the change to take effect.

How to Install the Latest Version Of Nvidia Drivers

Nvidia website maintains a page for it’s 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 396.24. Clicking the version number will take you to a page where you can see changelogs and whether you card is supported or not.

Unix Drivers_NVIDIA

The driver included in the default Ubuntu repository is 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 18.04. This operation becomes automatic on Ubuntu 18.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 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 risk, 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~gpu18.04.1) but it is not going to be installed
                     Depends: libnvidia-cfg1-396 (= 396.24.02-0ubuntu0~gpu18.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

Repalce 390 with your driver version number.

How to Uninstall the Proprietary Nvidia Driver on Ubuntu 18.04

If for some reason you don’t want the proprietary driver any more, 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 18.04 desktop, either from GUI or from 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: 14 Average: 4.6]

2 Responses to “2 Ways to Install Nvidia Driver on Ubuntu 18.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,

  • Christopher
    2 weeks 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

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.
  • * Some of my previous answers are lost after I uninstalled Disqus comment system from my website. I try to recover those answers whenever I can.