Build TensorFlow 1.2 from source with CUDA 8.0 and Cudnn 6.0 on Ubuntu 16.04

I want to compare the difference between native pip install and build from source for TensorFlow in terms of computation speed.


Basically, I first followed this blog post:

Install GPU TensorFlow From Sources w/ Ubuntu 16.04 and Cuda 8.0

However, 2 additional issues to solve:

  1. Need to use Bazel 0.5.2 instead of latest version. Latest version failed to build during my time.
    1. sudo apt-get purge bazel
    2. go to this link for installation of 0.5.2.
  2. If facing issue of “ImportError: cannot open shared object file: No such file or directory“, will need to follow below steps:
    1. sudo apt install nvidia-361-dev
    2. sudo find /usr/ -name '' (then you will know path of If it’s already inside /usr/local/cuda dir, no need for the 3rd step.
    3. just copy the to /usr/local/cuda/lib/
    4. Most importantly, reboot your machine!

If everything goes well, you can test your gpu like in this link.


I did a comparison between two VMs on Google Cloud – one using ‘pip install’ and another using build from source – with same hardware config and everything else. I ran a basic CNN model on CIFAR10 image set, and when using GPU, there is no difference in computation time. However, when I switched off GPU and used only CPU for computations, I noticed a reduced of processing time around 25% – 30%.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close