Building Tensorflow on POWER - CPU only

TensorFlow is a widespread software library for numerical computation using data flow graphs. It is very common on machine learning and deep neural networks projects. Therefore, today we are going to see how to install it on POWER with CPU only configuration.

tf logo

Update 09/2020

There is a easier way to install TensorFlow by using Anaconda and IBM Watson Machine Learning Edition, which will be taught in this tutorial.

Download and Install Anaconda package manager:

Remember to check the script sha256sum:
To install Anaconda Individual Edition, you just need to run the script downloaded and follow the inscructions that it provides.

Add WMLCE Channel to Anaconda

After the installation, add WMLCE (IBM Watson Machine Learning Community Edition) channel:

conda config --prepend channels \

Create an Anaconda Python3.6 environment for WMLCE and activate it:

Currently (09/2020) WMLCE only works with python version 3.6

conda create --name wmlce_env python=3.6 
conda activate wmlce_env 

Install TensorFlow

For CPU-only use, install TensorFlow with:

conda install tensorflow

TF is now installed and ready for use.


IBM Watson Machine Learning Community Edition:
WMLCE softwares list:


OUTDATED 09/2020 The following tutorial is an outdated way of installing TensorFlow on Power. If you still want to build TensorFlow from source by following this tutorial, proceed with caution.

Before installing TensorFlow, there are a couple of details we have to pay attention to:

  1. Due to Bazel, one of TF dependencies, the operating system must be Ubuntu 14.04 or Ubuntu 16.04.
  2. We are going to use Python 2.7, since TF doesn’t seem to be supported by Python 3.5 on POWER.

Tensorflow Dependencies

You can use the commands below to solve most of the dependencies:

apt-get update
apt-get install python-numpy python-dev python-pip python-wheel

Bazel installation

Bazel is one of the TF dependencies, but its installation is less intuitive than the others due to its community not officially supporting POWER architecture. That said, we must compile it from the Source. First of all, we need to install its own dependencies by the following commands:

apt-get update
apt-get install unzip build-essential python openjdk-8-jdk protobuf-compiler zip g++ zlib1g-dev

It is also important to add enviroment variables on .bashrc for JDK.

vi .bashrc
	export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-ppc64el
	export JRE_HOME=${JAVA_HOME}/jre
	export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
	export PATH=${JAVA_HOME}/bin:$PATH

For compiling Bazel, we are going to download and unpack its distribution archive (the zip file from the release page The .sh is not compatible with ppc64le) and compile it.

mkdir bazel
cd bazel
wget -c

if you want to download other version of bazel, this link must be switched by the one you are intenting to use.

Update 09/2020: It is also possible to perform the installation by following this tutorial.

As we can see, this tutorial was tested with bazel 0.11.1, but feel free to try other version and see if it works properly.

Also, if you are having any trouble about lack of resources, you can take a look on ‘Build issues and Support Websites’ to see if there’s any link that could help you. Anticipating: if you don’t have memory enough and your Bazel can’t complete the compile step, you might have a problem with the garbage collector of JAVA (and there’s a link which explains how to deal with it).

Installing Tensorflow

Since we are going to use the current version of TF, we need to clone it from the official GitHub and execute the configuration script.

git clone
cd ~/tensorflow

On this step, we have to specify the pathname of all relevant TF dependencies and other build configuration options. On most of them we can use the answers suggested on each question. Here, I will show how it was done for this tutorial. (Yours might be a little different, depending on the pathnames)

Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python2.7
Found possible Python library paths:
Please input the desired Python library path to use.  Default is [/usr/lib/python2.7/dist-packages]: /usr/lib/python2.7/dist-packages

Using python library path: /usr/local/lib/python2.7/dist-packages

#Y/N Answers given: All of them as suggested in each question.

Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: -mcpu=native
Configuration finished

To build and install TF, we use:

bazel build --copt="-mcpu=native" --jobs 1 --local_resources 2048,0.5,1.0 //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg #creates the pip package
pip install /tmp/tensorflow_pkg/tensorflow-1.5.0rc0-cp27-cp27mu-linux_ppc64le.whl #installs the pip package.

This name depends on your operating system, Python version and CPU only vs. GPU support. Therefore, check it out its name before this step.

By this moment, your TF must be working. Remember not to import it into its own directory: you have to chance directory before executing Python.

Build Issues and Support Websites:

While testing this tutorial, I could separate some useful issues reports and links to help some of the troubles you might have on the way.

  1. It solves a protobuf problem I had. It seems pretty common on PPC TF installation.
  2. This one is about local resources. If you are running out of memory (your build fails on C++ compilation rules), you have to specify your resources on the command line when you build TF. On the tutorial, it is already done.
  3. An official tutorial about how to install TF from Sources
  4. An official tutorial about how to install Bazel from Sources.
  5. IBM source about Tensorflow installation. Provides interesting information about bazel installation on PPC and how to install TF with GPU support. It also points to an IBM Bazel modified to PPC (which we are not using in this tutorial, but you can take a look on it).
  6. An issue about enviroment variables: on the configuration step, if it does not recognize some of the TF variables, this might help you to solve the problem.
  7. An issue about Bazel: “The system is out of resources”. You might need to add a command line on compile file to change the garbage collector size. On the issue on git, it’s suggested to change it to 384, but, at least on one of the computers I tried to compile, I needed to change it to 512 (in other words, change -J-Xmx384m on the solution line to -J-Xmx512m). It’s important to see that ideally we should not have to change the source code, but it solves the problem. Another option is to increase the memory of your system if it’s possible (recommended).