Linux (Ubuntu) and NVIDIA GPU support

If you want to use tensorflow-gpu, Flux.jl or any other library that benefits from GPU parallelisation, then you need to setup:

  1. Appropriate NVIDIA drivers
  2. CUDA
  3. cuDNN

Step 1: Installing appropriate drivers

In Linux Mint the appropriate NVIDIA drivers can be hard to determine, as the latest drivers on the NVIDIA website may not necessarily be the most ideal ones, a fact accepted by NVIDIA themselves in the Additional Information section when trying to download drivers here.

A foolproof method is as follows:

ISSUES: Although this method always works, it has multiple disadvantages. Firstly, the CUDA installation in the next step can mess up the drivers again. Secondly, the drivers that do work are always outdated. Updating them as you update CUDA and cuDNN can lead to clashes as well.

Step 2: Install CUDA

Check the appropriate CUDA version for the driver installed in Step 1 here. Follow the instructions to install from the CUDA website. If using Debian based distros, make sure to use the appropriate .deb files for installation. After installing CUDA with apt-get, also install nvidia-cuda-toolkit in the same way

Step 3: Install cuDNN

Get cuDNN from here and follow the installation instructions. The copy-paste technique works best!

Final step: Get GPU dependent packages working!

I use Flux.jl (julia) and tensorflow (python) for GPU-related tasks. Both these packages rely on a proper CUDA installation. In my experience, installing tensorflow from conda ensures proper CUDA installation for python.

You can now check if CUDA works on these two packages.

1. Tensorflow

Check using the following code

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

2. Julia

Check with CUDAnative and CuArrays by first installing with

import Pkg
Pkg.Add("CUDAnative")
Pkg.Add("CuArrays")

and then running

] test CuArrays

Bypass all above methods using Docker

I haven’t tried this but it is recommended by folks at TensorFlow: https://www.tensorflow.org/install/docker