The official-released binary packages of TensorFlow are built for newer version of Linux distros. Here is how to build TensorFlow binary package for CentOS 6.
Install Dependencies
Admin privilege is required here.
OpenJDK (for Bazel)
Developer Toolset (for Bazel and TensorFlow)
C++11 compatible compiler is required during the building process. Follow the instructions in this article to install Developer Toolset. It is worth noting that, in this case, installing just devtoolset-6-toolchain
would be sufficient.
Python 2.7 (for TensorFlow)
This step also requires Software Collections installed. Therefore, if you’ve installed Developer Toolset by following the instructions above, you should have no problem installing these dependencies.
Build and Install Bazel
Enter Build Environment
Enter Software Collection environment with Developer Toolset.
Prepare Source Code
Method 1 (Recommended)
The standard way of compiling a release version of Bazel from source is to use a distribution archive. From version 0.4.1, bootstrapping Bazel from GitHub repository is no longer supported as only the distribution archives contain generated artifacts required for direct compilation. Download bazel-<VERSION>-dist.zip
from the release page.
Method 2 (Only Works for Version <= 0.4.0)
Build and Install
Build TensorFlow with Bazel
Enter Build Environment
Enter Software Collection environment with Developer Toolset and Python 2.7.
Prepare Source Code
Since GNU C library version in CentOS 6 is less than 2.17, a slight modification needs to be applied before compilation.
Modify tf_extension_linkopts
function in tensorflow/tensorflow.bzl
from
to
Build
After above modification, we can now start building!
Remember to disable jemalloc when configuring — otherwise the build will fail.
Finishing Up
Finally, you will found a tensorflow-1.1.0-cp27-none-linux_x86_64.whl
(filename may vary upon versions) in /tmp/tensorflow_pkg/
. With this self-built binary package, we can now deploy TensorFlow to CentOS 6 by pip
.
Enter Python Environment on Deployment Target
Enter Python 2.7 environment either by Software Collection or by tools like pyenv.
Install
Depending on your environment setup, admin privilege might be needed here.