Solving Tensorflow 1.3 building issues on Linux

/ Sven Boesiger / Ubuntu

Compiling Tensorflow on Linux tends to be challenging when the build system lacks the proper dependencies. But problems might even occure if you have the required libraries and tools available for Bazel – Google’s build tool. Capitalizing on the knowledge gained from building the former version, I was quickly able to solve this versions compiling issues. I hope my solution will help you too. Please leave any comments or questions below.

The increase in speed, that can be achieved by compiling Tensorflow, is enormous and boosts the framework to the next level – the results are hence fully worth the hustle. In my case the acceleration using an optimized build are about factor 100x. Moreover, only the customized build allowed me to extend Tensorflow with my own ops.

The following steps were necessary, starting with Ubuntu 17.04, GCC 4.9.4 (compiling Tensorflow 1.2 required the downgrade formerly), to build the framework:

Upgrading Bazel to version 0.6.1:

sudo echo "deb [arch=amd64] stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade bazel

As with Tensorflow 1.3 certain dependencies most likely won’t download. As a workaround I set up a local HTTP server and distribute the “packages” manually. In my case Cython failed to download (while it was Protobuf in Tensorflow 1.2),


then add the following line to the tensorflow/tensorflow/workspace.bzl file under the urls section of the cython part:


and start the local HTTP server in the same directory as the downloaded file:

python -m SimpleHTTPServer 8000

finally the build worked:

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

Afterwards the building process went through pretty quickly.