How to Install Nvidia Drivers on Ubuntu 18.04

Install Nvidia drivers on Ubuntu 18.04
In this tutorial, I will show you how to install the latest Nvidia drivers on Ubuntu 18.04 Desktop from the terminal. It may happen that the graphics drivers included in Ubuntu for your graphics card are not fully adapted. In the case, it may be interesting to use the manufacturer's drivers.

There some video card and drivers available and you must know which one you can need to use:

  • Nvidia Nouveau driver: it is the open source implementation of the Nvidia driver. It's not on par with the official drivers but the speed of development and advancements gives confidence that this is an option to have and promote. For every new release the drivers get better and better but the updates are available less frequently than a PPA
  • Ubuntu Default Recommended Driver: Ubuntu does an amazing job of figuring out which Nvidia driver you need depending on the card you are using. But it's not up to date when compared with the official site or a PPA.
  • Nvidia PPA driver: it offers some great Performances and works out of the box for most cards by using the driver included in the PPA. It also offers the latest driver hours/days after it's official release and the installation is either through terminal or GUI.
  • Nvidia driver from official site: This is the official drivers such as the ones in the PPA but the difference is that they do not upgrade automatically and you can face some issues when updating, uninstalling and installing.

Detect nvidia graphic card model

It's important to detect the model of your Nvidia graphic card in order to install the required driver. To do that, there is a simple method in your terminal:

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
model    : GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M]
vendor   : NVIDIA Corporation
modalias : pci:v000010DEd00001140sv0000103Csd000021BBbc03sc02i00
driver   : nvidia-340 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

You can see the model of your Nvidia card and the recommended driver is nvidia-340. 

Install the Nvidia driver using PPA

Now that you can which card to install, you can now install it through the PPA. First, if you have already installed an old Nvidia driver, remove it

# apt purge nvidia*

Now you can add the PPA on your Ubuntu 18.04, notice that adding a PPA on Ubuntu 18.04 doesn't require the update command as for the previous version. You will see some useful information

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

 Fresh drivers from upstream, currently shipping Nvidia.

## Current Status

Current short-lived branch release: `nvidia-396` (396.24)
Dropped support for Fermi series (

Current long-lived branch release: `nvidia-390` (390.48)
Old long-lived branch release: `nvidia-384` (384.130)

For G8x, G9x and GT2xx GPUs use `nvidia-340` (340.106)
For NV4x and G7x GPUs use `nvidia-304` (304.137) End-Of-Life!

and now install the recommended driver

# apt install nvidia-340
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  bbswitch-dkms gnome-screensaver indicator-session lib32gcc1 libaccount-plugin-1.0-0
  libaccount-plugin-generic-oauth libaccount-plugin-google libc6-i386 libcgmanager0
  libcuda1-340 libjansson4 libnih-dbus1 lightdm mountall nvidia-opencl-icd-340
  nvidia-prime nvidia-settings ocl-icd-libopencl1 screen-resolution-extra
  signon-keyring-extension signon-plugin-oauth2 unity-control-center-signon
  unity-greeter upstart
Suggested packages:
  bumblebee bindfs lightdm-remote-session-freerdp lightdm-remote-session-uccsconfigure
  remote-login-service graphviz upstart-monitor

Now you have the driver installed. You can see all the latest Nvidia drivers if you want to try installing manually.

Install and choose Nvidia driver for hybrid card

You can see computers which have two graphics cards: Intel and Nvidia. In this case, you install the two and switch to choose the one to use. NVIDIA Optimus is the codename for the dual graphics card split enjoyed by a wide variety of "gaming" laptops with "dedicated" graphics. To check if you have a hybrid card, you can use the command below:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] (rev a1)

You can see the Intel and Nvidia cards presents. To easily manage the two cards, you can install Nvidia-prime or Bumblebee. You should notice that when you have a hybrid card, even if you install the Nvidia driver, it's not the one that is used by your system, you need Nvidia-prime or Bumblebee to switch on Nvidia and use it by default. The Nvidia-prime and Bumblebee packages didn't work together. You need to choose one of the two:

  • Nvidia-prime: it is NVIDIA's solution to implementing Optimus usability on Linux. That being said, NVIDIA Prime is closed-source. It also has an annoying tendency to drain laptop batteries, as the discrete card usually stays enabled due to the lack of per-application switching found on Windows.
# apt install nvidia-prime
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  bbswitch-dkms gnome-screensaver indicator-session libaccount-plugin-1.0-0 

It is able to decide on which card to use at profile level, i.e. when the user logs in. This decision is adjustable at NVIDIA X Server Settings control panel

  • Bumblebee: it is the open-source software community attempted to fix this with the creation of the Bumblebee project. Instead of using the always-on or always-off mode of Prime, Bumblebee created a utility called optirun that allows you to specify whether a program should be loaded with the discrete graphics card or not.
# apt install bumblebee linux-headers-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  bbswitch-dkms libbsd0:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
  libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libffi6:i386 libgl1-mesa-dri:i386

Now to launch your application with Nvidia use the command as below

# optirun playonlinux

Read also :

How to Remove and Add PPA on Ubuntu 18.04

How to Install NVIDIA Drivers using Debian Repository

Now you know the different ways to install and use your Nvidia drivers on Ubuntu. The latest versions bring more fixes and correct issues related to graphics corruption, HDMI support, thermal support and more for the latest Nvidia cards. Normally, updating the video drivers solves many issues.

10 Comments... add one

  1. This does not work on 18.04. It used to work on 16.04 where you goto additional drivers and select the proprietary driver. Now all they have are the metadata drivers. I tried your tutorial and I still get GLX issues. I have GTX960M (optimus) and I also installed Prime. The nvidia-settings wont open, and I don't have glx working either.

    The new 18.04 sucks and is super buggy and gives so many issues on the ASUS ROG laptops.

  2. got the ppa and tried to install nvidia-304 (yes, ancient) but ...

    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
    Depends: xserver-xorg-core but it is not going to be installed
    Recommends: nvidia-settings (>= 331.20) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    oh boy, another mystery ...

    • Hi,

      You can see the mention in the tutorial " For NV4x and G7x GPUs use `nvidia-304` (304.137) End-Of-Life! " which can help to understand why you probably have those dependencies errors.

  3. I had some issue when I was installing:

    error: paste subprocess was killed by signal (Broken pipe)Errors were encountered while processing:/var/cache/apt/archives/xserver-xorg-video-nvidia-410_410.57-0ubuntu0~gpu18.04.1_amd64.deb

    Well, if someone else is encountering this same issue, here is how to solve it:

    (This issue happens because the algorithm can't overwrite some files/derectories)

    run this on terminal as root:

    sudo dpkg -i --force-overwrite /var/cache/apt/archives/
    𝘡𝘩𝘦 .π˜₯𝘦𝘣 𝘧π˜ͺ𝘭𝘦𝘴 𝘡𝘩𝘦 𝘰𝘢𝘡𝘱𝘢𝘡 𝘴𝘒𝘺𝘴 (π˜ͺ𝘯 𝘡𝘩π˜ͺ𝘴 π˜₯π˜ͺ𝘳𝘳𝘦𝘡𝘰𝘳𝘺) π˜ͺ𝘴 𝘡𝘳𝘺π˜ͺ𝘯𝘨 𝘡𝘰 𝘰𝘷𝘦𝘳𝘸𝘳π˜ͺ𝘡𝘦)

    after running the previous command, run this other one:

    𝘴𝘢π˜₯𝘰 𝘒𝘱𝘡 -𝘧 π˜ͺ𝘯𝘴𝘡𝘒𝘭𝘭 -𝘺 && 𝘴𝘢π˜₯𝘰 𝘒𝘱𝘡 π˜ͺ𝘯𝘴𝘡𝘒𝘭𝘭 -𝘺 𝘯𝘷π˜ͺπ˜₯π˜ͺ𝘒-π˜₯𝘳π˜ͺ𝘷𝘦𝘳-'𝘡𝘩𝘦_π˜₯𝘳π˜ͺ𝘷𝘦𝘳_𝘷𝘦𝘳𝘴π˜ͺ𝘰𝘯_𝘺𝘰𝘢_𝘸π˜ͺ𝘴𝘩_𝘡𝘰_π˜ͺ𝘯𝘴𝘡𝘒𝘭𝘭'

    This solved the problem (to me).

  4. Thanks for this article. I had tried maybe a year ago to get Nvidia drivers to work on Ubuntu 18.04 & had failed back then. I can't remember what I tried back then but I was surprised at how easy it was with your instruction!

    • Hi Vance,

      Glad to hear that installation for Nvidia drivers went pretty well on Ubuntu 18.04. Soon we will test on Ubuntu 20.04.


Leave a Comment