sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev


CUDA 9.0 does not support gcc/g++ 7. Install gcc/g++ 6:

sudo apt-get install gcc-6 g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 40
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 40
sudo update-alternatives --config gcc

NVidia Driver


sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update
sudo apt-cache search nvidia
sudo apt-get install nvidia-396

Base Installer

sudo dpkg -i cuda-repo-ubuntu1704_9.0.176-1_amd64.deb
sudo apt-key adv --fetch-keys
sudo apt-get update

CUDA Toolkit

It seems Tensorflow does not supports CUDA toolkit 9.1 right now. Recommend to use runfile installation type.


Follow the instruction:

You are attempting to install on an unsupported configuration. Do you wish to continue?
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
Install the CUDA 9.0 Toolkit?
Enter Toolkit Location
[default location]
Do you want to install a symbolic link at /usr/local/cuda?
Install the CUDA 9.0 Samples?
Enter CUDA Samples Location
[default location]

Uninstall (refer

sudo /usr/local/cuda-9.0/bin/

Environment setup:

export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}



.Download cuDNN

Download the latest cnDNN from

For example: cuDNN v7.1 Runtime Library for Ubuntu16.04 (Deb) cuDNN v7.1 Developer Library for Ubuntu16.04 (Deb) cuDNN v7.1 Code Samples and User Guide for Ubuntu16.04 (Deb)

Installation refers to

sudo dpkg -i libcudnn7_7.1.1.5-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.1.1.5-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-doc_7.1.1.5-1+cuda9.0_amd64.deb


Copy the cuDNN sample to a writable path.

cp -r /usr/src/cudnn_samples_v7/ $HOME

Go to the writable path.

cd  $HOME/cudnn_samples_v7/mnistCUDNN

Compile the mnistCUDNN sample.

sudo make clean && make

Run the mnistCUDNN sample.


If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:

Test passed!


###= libcupti-dev library

sudo apt-get install cuda-command-line-tools-9.0

Install Tensorflow with Anaconda

conda create --name tensorflow python=3.6.5
source activate tensorflow
pip install --ignore-installed --upgrade

Validate Installation

Invoke python from your shell as follows:


Enter the following short program inside the python interactive shell:

# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()

If the system outputs the following, then you are ready to begin writing TensorFlow programs:

Hello, TensorFlow!