4

我想从源代码安装 bazel,并使用 bazel 在运行 redhat 6.7 的集群上编译 tensorflow。当我尝试安装 bazel 时,glibc 版本(2.12)太旧了。我没有对集群的 root 访问权限。在这种情况下可以安装 tensorflow 吗?

我的系统信息:

-bash-4.1$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
-bash-4.1$ which gcc
/usr/bin/gcc
-bash-4.1$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) 
-bash-4.1$ ldd --version
ldd (GNU libc) 2.12

该系统还安装了较新的 gcc。我尝试使用它,bazel仍然无法编译。

-bash-4.1$ /usr/local/gcc/4.8.4/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc/4.8.4/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc/4.8.4/libexec/gcc/x86_64-unknown-linux-gnu/4.8.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr/local/gcc/4.8.4
Thread model: posix
gcc version 4.8.4 (GCC) 

在编译 bazel 时,出现以下错误:

bazel-0.1.1/_bin/build-runfiles: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found

也有人报告了这个问题: https ://github.com/tensorflow/tensorflow/issues/110 和https://github.com/tensorflow/tensorflow/issues/527

如何在本地安装缺少的依赖项,并让 bazel 选择正确的库?

4

2 回答 2

3

您应该能够使用更新版本的 Bazel 导出 LD_FLAGS、CXX 和 CC 从源代码编译,并调整 Bazel 的 tools/cpp/CROSSTOOL 文件。如果您还有其他问题,请在 Bazel ( https://github.com/bazelbuild/bazel/issues )上打开一个 github问题。

我目前正在努力让这一切变得更容易。对不起,混乱。

于 2016-01-08T13:29:00.080 回答
1

如果有人需要手动执行此操作:

  1. 使用选项从源代码编译最新的 glibc、gcc 及其所有依赖项--disable-rpath,以避免将 glibc 路径硬编码为系统默认值。不要LD_LIBRARY_PATH直接添加 glibc,否则包括在内的所有可执行文件rm都将停止工作。

  2. 用你的 gcc 编译 python,安装 pip 和官方轮子

./configure --prefix=$PWD/build --enable-unicode=ucs4 --with-cxx-main=g++ && make && make install

  1. 使用以下命令启动 python 以加载正确的 glibc,其中 ${GLIBC_PATH} 是 glibc 的安装位置,创建别名

alias tensorflow='${GLIBC_PATH}/lib/ld-2.23.so --library-path ${GLIBC_PATH}/lib:${LD_LIBRARY_PATH}哪条蟒蛇'

  1. 导入tensorflow检查没有错误发生

在能够正确导入 tensorflow 模块后,您可以使用任何其他计算机(可能是您 PC 上的 ubuntu VM)来编译带有机器特定选项的自定义轮,并按照指南将其复制到您的集群

bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --copt=-msse4.1 //tensorflow/tools/pip_package:build_pip_package
于 2017-05-16T02:12:50.487 回答