I wrote a script to install the NVIDIA driver on Ubuntu.

You can simply run it like this to install the CUDA driver on a fresly installed Ubuntu VM:

curl https://raw.githubusercontent.com/johanburati/ms/master/ubuntu-install-cuda.sh | sudo bash

Or you can download it and run it with an option to install a specific version or purge the driver:

wget https://raw.githubusercontent.com/johanburati/ms/master/ubuntu-install-cuda.sh
chmod +x ubuntu-install-cuda.sh

The different options:

  • Install CUDA 9.1: sudo ./ubuntu-install-cuda.sh
  • Install CUDA 9.0: sudo ./ubuntu-install-cuda.sh 9
  • Install CUDA 8.0: sudo ./ubuntu-install-cuda.sh 8
  • Uninstall CUDA : sudo ./ubuntu-install-cuda.sh purge

Tested on

Date Image Kernel Result
2018-01-13 Canonical:UbuntuServer:16.04-LTS:latest 4.13.0-1005-azure OK
2018-01-14 Canonical:UbuntuServer:16.04-LTS:latest 4.13.0-1006-azure OK