1

I have been having a tremendous trouble installing Tensorflow on CentOS 6.9.

I tried to follow the instruction installing Tensorflow on CentOS using Anaconda3 (naturally for Python 3, Python 3.5.3 to be exact). Most of the packages installed correctly except for Tensorflow. I had to upgrade GCC version from 4.4.7 to 6.3.0 for installation of some packages, but it still says 4.4.7 on the Python screen.

Anyways, I did install Tensorflow according to the instruction, just not been able to use it because it throws this message ImportError: /lib64/libc.so.6: version 'GLIBC_2.14' not found (required by /home/k/anaconda3/envs/h/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so) .

So I tried to upgrade GLIBC to be newer than 2.14, so I upgraded binutils to 2.25 because binutils 2.20 would not run the configuration for one of the newer GLIBC file. However, I encountered another problem during configuration of GLIBC which was outdated Linux version. It required Linux 3.2.0, when I have Linux 2.6.

This is my constraint.

  • I cannot change the Linux version. It is a server machine, and I have to be on CentOS 6.9 Linux.

These are the questions that I want to ask everyone:

  1. I would love to change my GCC version from 6.3.0 to somewhere in between 5.0 ~ 5.2 because apparently CUDA 8.0 does not support GCC version after 5.3.1. When I type in gcc --version, I see GCC Version 6.3.0, but when I get on python 3, it shows me [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux. How should I go about it?

  2. I want to upgrade my GLIBC so that it would run Tensorflow on my platform. I believe the GLIBC version that I need to surpass is GLIBC_2.14, but I am unsure if that would be enough to run Tensorflow. Please please help me upgrade GLIBC so I can run Tensorflow on my server.

  3. In order to accomplish the tasks above, which binutil package do I need to have? I downloaded devtools-4-binutils to have the latest binutils packages, but I'm afraid that the latest package might not be in sync with Linux 2.6 version..

  4. If none of this work, could you please tell me how to reset GCC back to its factory version of 4.4.7, and binutils back to 2.20? If I can reverse all the modifications I have applied to the machine, I believe I will be able to install GCC version < 5.3.1 and configure the newer GLIBC for Tensorflow installation..

1

I had to rebuild the tensorflow pip package from source to make it work in CentOS 6 because there's some fundamental issue with the default pip package and which glibc was used to build it for CentOS6. Here's a memo I made of it. (Note I did this a month ago)

  1. download bazel-4.5-dist.zip and follow these steps to install, newer versions of bazel don't work as of 2017-09-04

    ~$ cd  
    ~$ wget https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-dist.zip  
    ~$ cd /usr/src  
    ~$ mkdir bazel-0.4.5-dist.zip  
    ~$ cd bazel-0.4.5-dist  
    ~# mv ~/bazel-0.4.5-dist.zip ./  
    ~# unzip bazel-0.4.5-dist.zip  
    ~# ./compile.sh
    
  2. Modify ~/.bashrc to activate devtoolset-2 instead of devtoolset-6. Tensorflow will not build with newer gcc, only up to gcc 4

    in ~/.bashrc

    source /opt/rh/devtoolset-2/enable
    #source /opt/rh/devtoolset-6/enable
    
  3. Clone tensorflow into /usr/src

    ~$ cd /usr/src  
    ~# git clone https://github.com/tensorflow/tensorflow
    
  4. Configure tensorflow

    ~$ cd tensorflow  
    ~# ./configure
    

Select "No" for all support options except CUDA. Everything else should be default

  1. go to /usr/src/tensorflow/third_party/gpus/crosstool modify CROSSTOOL_clang.tpl and CROSSTOOL_nvcc.tpl add the following line to the section labeled "toolchain"

    linker_flag : "-B/opt/rh/devtoolset-2/root/usr/bin"
    
  2. Build tensorflow

    ~$ cd /usr/src/tensorflow  
    ~# bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
    
  3. Create pip package

    ~# bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
    
  4. Install custom pip package

    ~# sudo pip install /tmp/tensorflow_pkg/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl
    
  • 1
    Worked for me with 2 little changes: 1. I had to add "-lrt" to linking flags ( "-Wl,-lrt,%s")to //condiftions:default in _rpath_linkopts in tensorflow.bzl file , or build would file with "undefined reference to `clock_gettime'", update setuptools and pip. – mestia Jul 12 '18 at 14:45
  • 1
    It might be useful to point out that bazel-0.4.5 does require jdk 1.8. I found steps to download and install here: digitalocean.com/community/tutorials/… – user200857 Nov 21 '18 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.