Skip to content
superstringer edited this page Apr 15, 2019 · 1 revision

GPU

Install Driver and CUDA for Ubuntu 18.04

Refer to link. It looks as though the CUDA 9.1 is actually in the official 18.04 repositories now. Run the following from a terminal window:

$ sudo apt install nvidia-cuda-toolkit 

After it is installed run the following to confirm the CUDA version

$ nvcc -V 

Driver installation

From source

First download the driver from the NVIDIA website (e.g. NVIDIA-Linux-x86_64-340.87.run), then shut down the X server by

$ sudo service lightdm stop

then start running the driver installation

$ sudo ./NVIDIA-Linux-x86_64-340.87.run

From repo

$ sudo apt-add-repository ppa:xorg-edgers/ppa

To revert to official packages

$ sudo ppa-purge xorg-edgers

or refer to this link

$ sudo apt-get install nvidia-340
$ sudo apt-cache search nvidia-cuda
$ sudo apt-get install nvidia-cuda-toolkit

Maintain the driver

The nvidia driver is a kernel driver, that needs to be compiled/linked against each kernel. If we update the linux kernel, the nvidia driver needs to be recompiled, from source. dkms is 'dynamic kernel module support'. dkms handles recompiling any such drivers, including the nvidia driver, automatically, whenever the kernel is updated. So we just install dkms

$ sudo apt-get install dkms

Tensorflow

Install CUDA Toolkit

First download the runfile from https://developer.nvidia.com/cuda-downloads, then do

$ sudo service lightdm stop
$ sudo sh cuda_8.0.44_linux.run

then download cuDNN from https://developer.nvidia.com/cudnn and do

$ tar xvzf cudnn-8.0-linux-x64-v5.1.tgz
$ sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

then we add the following lines in the ~/.bash_profile

  #CUDA
  export CUDA_HOME=/usr/local/cuda
  export PATH="$CUDA_HOME/bin:$PATH"
  export LD_LIBRARY_PATH="$CUDA_HOME/lib64:$LD_LIBRARY_PATH"

finally we do

$ pip install tensorflow

or

$ pip install tensorflow-gpu

for the GPU support.

Clone this wiki locally