This post is for you if you are looking to install TensorFlow 1.0 from source on ubuntu 14.04 on AWS machine with GPU support(CUDA). Quick Summary of setup:

OS: ubuntu 14.04

Cloud: AWS P2.xlarge instance

TensorFlow version: 1.0.0-rc1

Bazel Version: 0.4.4

CuDNN: 5.1

CUDA: 8.0

Once you have launched an AWS P2.xlarge instance with ubuntu 14.04, follow these instructions to install TensorFlow.

Install TensorFlow 1.0.0 from source:

  1. Basic dependencies for TensorFlow:

2. Bazel Installation:

Bazel is the build tool used by TensorFlow. we are going to use bazel release 0.4.4 for ubuntu.

a) Java Installation: Java is a dependency of Bazel so let’s install that.

(If and only if you are on a VPC, then you have to add your private ip to the host file:

)

Add the ppa and install Java:

Accept the terms and conditions and Java 8 will be installed.

b) Bazel: We are going to install Bazel. We are going to create a directory installation in home(~) which is /home/ubuntu and download all our installation files there.

Bazel is now installed.

Add the following to your bashrc file:

Now, run the .bashrc file to make sure that the changes made start reflecting in current session.

3. CUDA installation:

Check whether cuda is installed or not by typing:

Output will look like this:Image showing output of nvidia-smi

4. Cudnn installation:

You need to go to Nvidia developer site, register there and after answering too many questions, you shall get your hands on Cudnn 5.1 for linux for cuda 8. You need to upload that to your server and follow these steps:

5. Install TensorFlow-1.0:

Now, it will ask you many questions, answers to most of them is the default option, except for the GPU support, which should be answered as y, for the rest you could simply press Enter key. In the end it shall ask for compute capacity, for which enter 3.7 which is the compute capacity of AWS P2.xlarge instance.

install Tensorflow

Add these to your ~/.bashrc file

Now, run the .bashrc on command line to make sure that changes just made start reflecting in current session.

Congratulations! Tensorflow has been installed. In the next step we shall verify the installation.

6. Testing the installation:

   a). Testing basic installation and version:

If your installation is not correct, you shall get errors and will not be able to print version. But if it prints the version correctly, it means Tensorflow has been installed.

b). Test GPU settings:

Another thing that we need to check is whether CUDA has been installed correctly and we are able to run Tensorflow code on GPU. Let’s run the following code.

Expected output would mention the device it ran on before it produces output.

 

Please note the device it runs on. It should be /gpu:0. If you get /cpu:0 in the output, it means your GPU configuration is wrong.) Because if GPU is available and properly configured then Tensorflow always runs it on GPU first.

See my screenshot:

intall Tensorflow on GPU

It’s giving some more instructions on how we can run TensorFlow on CPU faster by using SSE4.2 etc. However, we don’t intend to run TF on CPU. So, we are going to ignore them.

Now, you have a installed Tensorflow-1.0 on AWS server. Follow this quick tutorial to start learning Tensorflow.

Edit: May 9, 2017: Updated the libtiff version to libtiff5-dev from outdated libtiff4-dev.