Reputation: 33
when i install tensorflow on my centos 6.5, i got a problem, i install tensorflow by code below:
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
even though i could pip list the modules:
# pip list
numpy (1.11.0)
pandas (0.18.0)
pip (1.5.4)
protobuf (3.0.0b2)
python-dateutil (2.5.3)
pytz (2016.4)
redis (2.10.5)
setuptools (20.10.1)
six (1.10.0)
tensorflow (0.8.0)
.......
but when import the module i got this error:
import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 45, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/python27/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /usr/local/python27/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)
so how could i fix it , any suggestion will be appreciated
Upvotes: 3
Views: 7394
Reputation: 629
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)
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
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
Clone tensorflow into /usr/src
~$ cd /usr/src
~# git clone https://github.com/tensorflow/tensorflow
Configure tensorflow
~$ cd tensorflow
~# ./configure
Select "No" for all support options except CUDA. Everything else should be default
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"
Build tensorflow
~$ cd /usr/src/tensorflow
~# bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
Create pip package
~# bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
Install custom pip package
~# sudo pip install /tmp/tensorflow_pkg/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whl
Upvotes: 0
Reputation: 63
I tried installing from conda. First I installed anaconda installation. When I installed Tensorflow from conda as mentioned https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html#anaconda-installation I got the same error. I tried installing the new GLIBC_2.14 version from the following answer How to upgrade glibc from version 2.12 to 2.14 on CentOS? It sort of worked, because I was no more getting the GLIBC_2.14 not found error, but instead I am getting a new error which is segmentation failure error.
(tensorflow) [jaswant.jonnada@batman ~]$ export LD_LIBRARY_PATH=/opt/glibc-2.14/lib
(tensorflow) [jaswant.jonnada@batman ~]$ python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow
Segmentation fault
Edit[1] The segmentation error also has a work around. You need to import numpy and matplotlib before importing tensorflow. Not sure how it got fixed by doing so, but it got fixed.
(tensorflow) [jaswant.jonnada@batman ~]$ python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy
>>> import matplotlib
>>> import tensorflow as tf
>>>
Upvotes: 4