Skip to content

Instantly share code, notes, and snippets.

@dichotomies
Last active February 24, 2017 18:03
Show Gist options
  • Save dichotomies/410f85058f7a16d4614d664446bf90c9 to your computer and use it in GitHub Desktop.
Save dichotomies/410f85058f7a16d4614d664446bf90c9 to your computer and use it in GitHub Desktop.
Installing TensorFlow with GPU support on Ubuntu 16.04

Install nvidia driver:

add-apt-repository ppa:graphics-drivers/ppa
apt-get update
apt-get install nvidia-<version number>

Verify installation by executing nvidia-settings -q NvidiaDriverVersion.

Load CUDA from https://developer.nvidia.com/cuda-downloads.

Run CUDA installer. Select default values for questions except for nvidia driver (select no).

sudo sh cuda_8.0.61_375.26_linux.run

A warning should occur, ignore it. Fix it by adding following lines into bash.rc (or other bash config):

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Take care, the cuda version is assumed to be 8.0. Otherwise change the exports accordingly.

Optional: Install pip and python-dev packages: sudo apt-get install python-pip python-dev.

Optional: Upgrade pip: pip install --upgrade pip.

Install the TensorFlow gpu version: sudo pip install tensorflow-gpu.

Download cuDNN from https://developer.nvidia.com/cudnn.

Install cuDNN by copying it's contents into the CUDA folder:

sudo tar -xvf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local

In case of correct installation, importing tensorflow in Python should result in following output:

I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment