GPU support for Artificial Intelligence

How to compile and install last NVIDIA drivers and CUDA support for IA (TensorFlow, PyTorch)

Fabricio Costa
- 08/23/2020 - 1 min. de lectura

We can find how many software tools are embedding IA technologies in their source development, including Odoo, and our beloved Moldeo platform.


The most popular tools you will here about are TensorFlow and Pytorch but even if we have some nice tools like ml5.js for javascript, the challenge of training your algorithms can become a real nightmare if you dare to use your poor little laptop for realworld IA tasks. If you have a descent dedicated GPU hardware (specifically NVidia) you can convert your laptop in a fair piece of IA development platform.
The first thing to do is to install the latest drivers of NVIDIA. I really suggest to make your experiments on a new linux partition with at least 50 GB if you dont want to mess up your working OS, then maybe upgrade it later after you have tested al the new working stuff in your hardware.

TensorFlow requires and use now CUDA and cuDNN. cuDNN is the Neural Network gpu developer library. We will use CUDA 10.0 with cuDNN 7.6.5

Hopefully, there is a nvidia official repository now that you have to add to you apt source list.

1. Add the official nvidia PPA drivers for linux:

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

2. Then update your nvidia drivers, purging the old one before.

sudo apt remove --autoremove nvidia-driver*
sudo apt remove --autoremove nvidia-cuda-toolkit
sudo apt remove --autoremove nvidia-*
sudo apt install nvidia-drivers-440

3. Add the keys and repository for CUDA

sudo apt-key adv --fetch-keys  http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda_learn.list'

4. Install CUDA for TensorFlow  (at this time i could compile TensorFlow with CUDA 10.0 support, 10.1 and 10.2 failed)

sudo apt update
sudo apt install cuda-10-0


Acerca de:

Fabricio Costa