操作系统版本centos 6.5

gcc版本:4.4.7

glibc版本:2.12

python版本:2.7.3

tensorflow:1.4.0    需要glibc GLIBC_2.17、CXXABI_1.3.7、GLIBCXX_3.4.19

yum install gcc

python get-pip.py

zipimport.ZipImportError: can't decompress data; zlib not available

yum install zlib-devel    #重新编译python,问题解决

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

yum install openssl-devel    ##重新编译python,问题解决

#安装python

cd Python-2.7.13

./configure --prefix=/data/machine/python --enable-unicode=ucs4

make && make install

chown -R machine.machine /data/machine/python

#安装pip

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

#安装tensorflow

pip install tensorflow

#pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow


#查找需要更新的版本

cd /data/machine/python/lib/python2.7/site-packages/tensorflow

find ./ -name *.so |xargs ldd

./libtensorflow_framework.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.17' not found (required by ./libtensorflow_framework.so)

./libtensorflow_framework.so: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.7' not found (required by ./libtensorflow_framework.so)

统计发现

/lib64/libc.so.6                GLIBC_2.17

/usr/lib64/libstdc++.so.6    CXXABI_1.3.7、GLIBCXX_3.4.19

#升级glibc

#glibc升级采用编辑完成后,只更新libc.so.6。存在如下文件。故采用全新升级glibc文件

ls: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument

tar xf glibc-2.17.tar.gz

cd glibc-2.17

mkdir build

cd build

../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

make

make install    #建议不采用ssh执行,通过不依赖操作系统的方式执行;更新的部分库文件,ssh也依赖

#升级gcc

tar xf gcc-4.8.1.tar.gz

cd gcc-4.8.1

./contrib/download_prerequisites

#建立build_gcc_4.8.1目录,这个目录和gcc-4.8.1平行

cd ..

mkdir build_gcc_4.8.1

cd build_gcc_4.8.1

#执行编译过程

../gcc-4.8.1/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib

make -j23


find ./ -name libstdc++.so.6.0.18

将找到的libstdc++.so.6.0.18,拷贝到/usr/lib64/

chmod 755 /usr/lib64/libstdc++.so.6.0.18


更新连接文件

rm -rf /usr/lib64/libstdc++.so.6

LD_PRELOAD=/usr/lib64/libstdc++.so.6.0.13 ln -s /usr/lib64/libstdc++.so.6.0.18 /usr/lib64/libstdc++.so.6

#LD_PRELOAD,是个环境变量,用于动态库的加载,动态库加载的优先级最高,一般情况下,其加载顺序为LD_PRELOAD>LD_LIBRARY_PATH>/etc/ld.so.cache>/lib>/usr/lib

ls     #测试命令是否正常,如果存在问题,采用如下办法回退

回退办法

rm -rf /usr/lib64/libstdc++.so.6

LD_PRELOAD=/usr/lib64/libstdc++.so.6.0.13 ln -s /usr/lib64/libstdc++.so.6.0.13 /usr/lib64/libstdc++.so.6


参考文章:

http://www.tensorfly.cn/tfdoc/get_started/introduction.html

http://blog.csdn.net/u013735511/article/details/76147138

https://github.com/qiwsir/ITArticles/blob/master/Linux/upgrade_gcc_on_Centos.md