Please find GPU model:
lspci | grep ' VGA 'From your GPU model, find its computing capability, which driver your GPU can use. You can find this information on https://developer.nvidia.com/cuda-gpus (there is also a table at https://en.wikipedia.org/wiki/CUDA). We prefer to install CUDA and NVIDIA GPU driver at the same time. If you just want to install the driver, and cuda separately you can follow https://linuxconfig.org/how-to-install-the-latest-nvidia-drivers-on-ubuntu-16-04-xenial-xerus .
We will install CUDA 10.0 from NVIDIA. The package needs to be download from https://developer.nvidia.com/cuda-10.0-download-archive Select the deb network version and download the .deb file. Go to the folder where the .deb file was downloaded and add exection permsision to it:
cd ~/Downloads
chmod +x cuda-repo-ubuntu1604_10.0.130-1_amd64.debThen follow the instructions given on https://developer.nvidia.com/cuda-10.0-download-archive with the installer
sudo dpkg -i cuda-repo-ubuntu1604_10.0.130-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt update
apt-cache show cuda-10-0Now select the package version and install CUDA
sudo apt install cuda-10-0=10.0.130-1
echo "export PATH=/usr/local/cuda-10.0/bin:/usr/local/cuda-10.0/NsightCompute-1.0${PATH:+:${PATH}}" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> ~/.bashrcReboot the PC and do sanity check:
nvidia-smi
nvcc -VIn order to select the CUDNN package version that fits to your GPU model, look for the configuration of requirements at https://docs.nvidia.com/deeplearning/sdk/cudnn-support-matrix/index.html For example a GPU model Quadro M2000M, has compute capability of 5.0 (Maxwell) and is suported by libcudnn7.6.4. So we now just need to install the version compatible with Cuda 10.0 with this model
apt-cache show libcudnn7-devAnd then we select the good package version that is compatible with CUDA 10 (7.6.4.38-1+cuda10.0)
sudo apt install libcudnn7-dev=7.6.4.38-1+cuda10.0In order to test if you have your NVIDIA driver, CUDA and CUDNN properly installed, you can test all with TensorFlow in a single command. To install tensorflow:
sudo apt install python-pip
pip install tensorflow-gpu==1.14.0And then:
python -c "import tensorflow as tf; print(tf.test.is_gpu_available())"If everything is ok you will have a True printed at the end of the messages.
OBS: after the sanity check you can remove tensorflow if the library is not useful to your projects with pip uninstall tensorflow-gpu