How to Install Nvidia Drivers on Ubuntu 18.04

In this article, I will show you how to install 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 on Ubuntu 18.04

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 (https://nvidia.custhelp.com/app/answers/detail/a_id/4656)

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.

Alain Francois 4:15 am

About Alain Francois

IT Linux administrator passionate of free and open source software, I work on Linux Systems since some years on installations and deployments of certain solutions. I like to share my experiences with a wider audience by training and conferences.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.