*  Ubuntu 16.04 LTS : installation of CUDA 6.5 to 8.0

The objective here is to propose a method of installation making it possible to make cohabit several versions of CUDA.

The installation described here was done the 10/26/2016 on a freshen udpate system by using :

sudo apt update
sudo apt upgrade

We first install the nvidia driver version 367.

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-367

To avoid some warning messages in CUDA installation, we install ubuntu packages libxi-dev, libxmu-dev and libglu1-mesa-dev

sudo apt install libxi-dev libxmu-dev libglu1-mesa-dev

To avoid some error messages when using nvcc compiler

/usr/local/cuda-7.0/bin/..//include/host_config.h:105:2: error: #error -- unsupported GNU version! gcc 4.10 and up are not supported!

we install gcc 4.7 (there some troubles with 4.9 version)

sudo apt install gcc-4.7 g++-4.7 gfortran-4.7

We reboot the computer and now we really can install CUDA 8.0. As we want to conserve previous CUDA installation, we don’t use .deb or .rpm packages and we choose the runfile (local) version from https://developer.nvidia.com/cuda-download. So we obtain the file cuda_8.0.44_linux-run

chmod u+x cuda_8.0.44_linux-run
sudo ./cuda_8.0.44_linux-run --silent --toolkit --samples --samplespath=/usr/local/cuda-8.0/samples --override

Due to an unsupported compiler (version 5.4.0), I use –override option for CUDA 6.5 to 7.5 installation.

chmod u+x cuda_*.run
sudo ./cuda_6.5.14_linux_64.run --silent --verbose --toolkit --samples --samplespath=/usr/local/cuda-6.5/samples --override
sudo ./cuda_7.0.28_with_346.75_linux.run --silent --verbose --toolkit --samples --samplespath=/usr/local/cuda-7.0/samples --override
sudo ./cuda_7.5.18_linux.run --silent --verbose --toolkit --samples --samplespath=/usr/local/cuda-7.5/samples --override
sudo ./cuda_8.0.44_linux-run --silent --verbose --toolkit --samples --samplespath=/usr/local/cuda-8.0/samples

Verify that the symbolic link /usr/local/cuda is linked to the default version you want otherwise correct it. For example :

sudo ln -fs /usr/local/cuda-8.0 /usr/local/cuda

Please make sure that

where <CUDA_VERSION> must be replaced by the version you want to use.