Install NVIDIA Driver for CUDA in Ubuntu/LinuxMint

Alex Punnen
Better ML
Published in
2 min readJun 26, 2018

Note — Before you start!

There is a high chance that your Linux distro GUI may be corrupted by these steps, In that case, you will be logged in a terminal window and please use the following the recover your GUI via https://askubuntu.com/a/206289/423906

First try purging the nvidia-driver (step 1) below, and if that does not help, try the rest. You can open a terminal with Ctrl + Alt+T keys combo in case you lost your GUI

1.sudo apt-get remove --purge '^nvidia-.*'
2.sudo apt-get install ubuntu-desktop
3.sudo rm /etc/X11/xorg.conf
4.echo 'nouveau' | sudo tee -a /etc/modules

Note — Even your display is okay, still if your GPU is not having sufficient memory, you could use the above to purge.

Update 2020

Use this https://www.tensorflow.org/install/gpu#linux_setup

and ignore below

Older Post

Step 1: First find the right driver for your GPU Card

Go to https://www.nvidia.com/Download/index.aspx and fill details

Search

You will get the driver version to install; Here it is 390

Step 2: Install the Driver

Note — never install directly from NVIDIA’s .run file as it messes with the display — lightdm and instability (unless you are an OS expert, please see — basically install without opengl --no-opengl-file) and if you still mess with display there are enough threads to help you)

Open a shell prompt and add the Personal Package Archive for Graphics Drivers to Ubuntu

 sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update

Aftet that search if the package is available by adding “nvidia-” to the driver version number (390 see above how we got that)

:~# sudo apt-cache search nvidia-390
nvidia-387-dev - Transitional package for nvidia-390-dev
nvidia-387 - Transitional package for nvidia-390
nvidia-390-dev - NVIDIA binary Xorg driver development files
nvidia-390 - NVIDIA binary driver - version 390.67

Then install it

sudo apt-get install nvidia-390

Reboot the system and check

lsmod | grep nvidia

If the installation is successful you, similar to

nvidia_uvm            757760  0
nvidia_drm 40960 2
nvidia_modeset 1110016 5 nvidia_drm
drm_kms_helper 167936 2 i915,nvidia_drm
nvidia 14352384 148 nvidia_modeset,nvidia_uvm
drm 360448 8 i915,nvidia_drm,drm_kms_helper
ipmi_msghandler 45056 2 nvidia,ipmi_devintf

In case you do not want automatic updates for your driver (automatic updates are better not done)

sudo apt-mark hold nvidia-390

Note — If you go into a Login loop, or no Screen or GUI comes after reboot after updating the driver, follow these steps — https://askubuntu.com/a/1145520/423906

--

--

Alex Punnen
Better ML

SW Architect/programmer- in various languages and technologies from 2001 to now. https://www.linkedin.com/in/alexpunnen/