Omar Jamil

science * data

Where I work, the compute clusters have been upgraded to RedHat Eneterprise Linux 7 (RHEL7). I therefore needed to rebuild Tensorflow. I have to build because the standard pip install binaries do not work on these systems as the glibc version is 2.17 on RHEL 7 while Tensorflow >= v1.14 need glibc 2.23. (See my RHEL6 post)

First of all create a new conda environment, using anaconda3:

conda create -n tensorflow pip python=3.6

Note: The Tensorflow version being used here does not work with python 3.7 as there as some keywords being used that are now reserved in python 3.7 e.g. async and wait.

Get hold of tensorflow from:

git clone https://github.com/tensorflow/tensorflow tensorflow
cd tensorflow
git checkout r1.13

In order to build TF, need bazel. Again, do this with Conda:

conda install -c conda-forge bazel

This will install bazel v0.20 (the latest on conda forge at the time of writing this post). That is the reason for using TF r1.13; later version rquire bazel v0.24

You also need the following dependencies for Tensorflow build:

pip install -U --user pip six numpy wheel setuptools mock future>=0.17.1
pip install -U --user keras_applications==1.0.6 --no-deps
pip install -U --user keras_preprocessing==1.0.5 --no-deps

cd tensorflow
./configure 

And go through all the options. Said no to everything I think — building with CPU support only. My system did not have CUDA tools installed and I do not have root access.

Also, in build options prompt add --linkopt=-lrt, then

bazel build //tensorflow/tools/pip_package:build_pip_package --incompatible_remove_native_http_archive=false

If you are lucky, this will build it successfully. Now build the python wheel package using:

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

And then install with

pip install /tmp/tensorflow_pkg/tensorflow-1.13.1-cp36-cp36m-linux_x86_64.whl

And that should be it! Test the installation in python interpreter with

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

Recent posts

About

A scientist using Machine Learning to do Physics