Install latest NVIDIA drivers for Linux Mint 19/Ubuntu 18.04

If you have NVIDIA graphic card like GTX 1080 and you want to do something cool with the card you will need latest drivers. In order to install latest driver you have two ways: using Ubuntu default repository or download drivers from Ubuntu site. You can check both ways here:

Two videos on the topic:

Note: I prefer to not use third party repositories. For Ubuntu 18.04 and Linux Mint 19 nvidia drivers 390 from the official repository works fine even for libraries like tensorflow and CUDA toolkit.

Note 1: You can download drivers like: 415.25, 418.43 but they could cause problems. That's why I prefer to stick to the recommended ones.

Before installing a new driver you can check the recommendations for the driver. For example 418.43:

Support for New GPU
* GeForce GTX 1660 Ti
* GeForce RTX 2070 with Max-Q Design
* GeForce RTX 2080 with Max-Q Design

Install the recommended using standard Ubuntu Repository

This is easiest method and recommended for new users.

Linux Mint 19

  • Menu
  • Administration
  • Driver manager
  • NVIDIA Corporation
    • select nvidia-driver-390 (recommended) - and unselect xerver-xorg-vidieo-nouveau
  • Apply and restart

The correct drivers would look like to:

Linux Mint / Ubuntu 18.04

For Ubuntu and terminal lovers you can do:

ubuntu-drivers devices

the output should be:

== /sys/devices/pci0000:00/0000:00:03.1/0000:20:00.0 ==
modalias : pci:v000010DEd00001B80sv00001458sd00003702bc03sc00i00
vendor   : NVIDIA Corporation
model    : GP104 [GeForce GTX 1080]
driver   : nvidia-396 - third-party non-free
driver   : nvidia-driver-390 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

Now you can install drivers by:

sudo ubuntu-drivers autoinstall

Or you can install specific version by:

sudo apt install nvidia-driver-390

or for 3.96

sudo apt install nvidia-driver-396

Note: before it was working as:

sudo apt install nvidia-390

or you can add some repos in order to make it work again.

Manual installation of recommended or latest

Check what drivers are installed

dpkg --get-selections | grep nvidia

The output should be something like:

$ dpkg --get-selections | grep nvidia
libnvidia-cfg1-390:amd64			install
libnvidia-common-390				install
libnvidia-compute-390:amd64			install
libnvidia-compute-390:i386			install
libnvidia-decode-390:amd64			install
libnvidia-decode-390:i386			install
libnvidia-encode-390:amd64			install
...
nvidia-kernel-common-390			install
nvidia-kernel-source-390			install
nvidia-prime					install
nvidia-settings					install
nvidia-utils-390				install
xserver-xorg-video-nvidia-390			install

If you have mixed drivers like 3.90 and 3.96 this could cause a problem. It's better to remove older drivers in order to avoid conflicts. The nvidia drivers can be uninstalled by:

sudo apt-get purge nvidia*

Download latest driver or a version that you like:

Visit: NVIDIA Driver Downloads and select:

  • Product Type: GeForce
  • Product Series: GeForce 10 Series
  • Product GeForce GTX 1080
  • Operating System: Linux 64-bit
  • Language: English

Note you can download the latest one like: NVIDIA-Linux-x86_64-418.43.run or old version by searching in google. For example searching for: NVIDIA-Linux-x86_64-390.48.run

Once donwloaded you can Install the driver by:

sudo sh NVIDIA-Linux-x86_64-390.48.run

you may need to run it without user interface only from terminal

The ouput will be something like:

LINUX X64 (AMD64/EM64T) DISPLAY DRIVER
 
Version:	390.77
Release Date:	2018.7.16
Operating System:	Linux 64-bit
Language:	English (US)
File Size:	78.89 MB

You can check also for all supported cards on SUPPORTED PRODUCTS tab:

NVIDIA TITAN Series:
NVIDIA TITAN V, NVIDIA TITAN Xp, NVIDIA TITAN X (Pascal), GeForce GTX TITAN X, GeForce GTX TITAN, GeForce GTX TITAN Black, GeForce GTX TITAN Z

GeForce MX100 Series (Notebook):
GeForce MX150, GeForce MX130, GeForce MX110

GeForce 10 Series:
GeForce GTX 1080 Ti, GeForce GTX 1080, GeForce GTX 1070 Ti, GeForce GTX 1070, GeForce GTX 1060, GeForce GTX 1050 Ti, GeForce GTX 1050, GeForce GT 1030

Verify if driver is installed

After the installation of nvidia driver you can reboot and check output of this command:

nvidia-smi 

Everything is OK if the output is something like:

Mon Aug 20 15:18:58 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48                 Driver Version: 390.48                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:20:00.0  On |                  N/A |
|  0%   46C    P8    15W / 200W |    528MiB /  8116MiB |      2%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1291      G   /usr/lib/xorg/Xorg                           255MiB |
|    0      1826      G   cinnamon                                      93MiB |
|    0      2045      G   ...-token=0131A404F88EDFB69CFBE87FE27CF2B5     8MiB |
|    0      2776      G   ...-token=4213622D51C92E34E15CBCBCB028F7CA    60MiB |
|    0     25949      G   ...-token=81FD9A54DC3DB7C8FBAA2380BC4090AB    68MiB |
|    0     26937      G   ...-token=730AF28A86DCED16D77B4CD5AF0378A4    39MiB |
+-----------------------------------------------------------------------------+

Otherwise you will need to repeat previous steps by cleaning the drivers and install them again.

Command 'nvidia-smi' not found, but can be installed with:

sudo apt install nvidia-340
sudo apt install nvidia-utils-390

Broken drivers and GUI

Reasons

The drivers could be broken due to update of the Kernels. Recently update of the kernel broke my nvidia drivers. The update was for kernel: 4.15.0-46-generic

You can check your kernel version by:

uname -r

And check the driver by:

nvidia-smi 

If you get an error message from nvidia-smi:

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

Then you need to reinstall the drivers. Or even completely uninstall them and install them as a fresh installation.

You can try to repair the old driver - but usually this is not working for me:

sudo apt-get -f install

or

sudo apt install aptitude
sudo aptitude install (package name)

or to reload the driver:

sudo apt install --reinstall nvidia-390

So the best option here is purge and reinstall.

Another possible indication for problematic drivers are:

  • Software Rendering Mode
  • nouveau driver is loaded instead of the nvidia

This indicates a problem with graphic drivers. And it's always a good idea to check the Linux Mint logs for problems related to your GPU or system:

  • Menu
  • Administration
  • Logs

What to do

If the drivers are mixed, incomplete or broken and the drivers UI is not working as expected and cause crash for the Linux Mint (Ubuntu), which enter in special rendered mode. Then you can follow the next steps:

  • Menu
  • Administration
  • Driver Manager
  • Check what driver you have installed

If you have mixed drivers they will look like:

Your system still may work fine and you to not have problems. But a change of the drivers will cause a disaster and you may need to apply the steps here:

Download the recommended file for your system - you can check which one from the Driver Manager. And download it from NVIDIA-Linux-x86_64-390.77.run - recommended

  • Log out from all applications in order to prevent information loss
  • Press CTRL + ALT + F1 - in order to start new console mode
    • Press CTRL + ALT + F7 - to restore the previous mode (if GUI is working or sudo service lightdm start if it is stopped)
  • Then you need to enter stop the X server or the GUI and enter only in console mode. Starting and stopping the X server is done by:
sudo service lightdm start
sudo service lightdm stop
  • Clean old drivers (optional)
sudo apt-get purge nvidia*

or:

sudo apt-get purge nvidia-*
sudo apt-get autoremove --purge
  • Remove broken packages to different driver - 396 for example (optional)
sudo dpkg -r libcuda1-396
sudo dpkg -r nvidia-opencl-icd-396

found by this command:

dpkg -l | grep -i nvidia
  • Clean wrong repos (optional)

  • Menu

  • Administration

  • Update Manager

  • Edit

  • Software Sources ( or search in Menu )

  • Additional repositories

  • Clean not need or duplicated:

    deb file:///var/cuda-repo-9-0-local /
    deb file:///var/cuda-repo-9-2-local /

In this case Cuda 9.2 should be removed as not needed. Due to some problems with tensorflow and latest CUDA. More info: Install Tensorflow with NVIDIA GPU on Ubuntu

  • Change the file to executable
chmod +x NVIDIA-Linux-x86_64-390.77.run
  • Finally install the new driver by:
sudo sh ~/Downloads/NVIDIA-Linux-x86_64-390.77.ru

Update and hold of drivers

Sometimes or may want to prevent updating of the drivers this can be done by command:

sudo apt-mark hold nvidia-390

to unhold and revert previous command you can do:

sudo apt-mark unhold nvidia-390

Note: Sometimes you can switch the rendering modes by:

  1. Boot into Linux Mint Cinnamon
  2. Log out
  3. Select:
    • "Cinnamon" (Ci)
    • "Cinnamon (Software Rendering)" (C2)
  4. Log in as usual
  5. Linux Mint will start with the selected mode and will automatically pick it as default session after reboot

Driver update via update manager

You can select additional libs to be added during Linux Mint installation - codecs and some other libs which can impact the graphics: