【问题标题】:How to install bazel and tensorflow on Red Hat 6.7如何在 Red Hat 6.7 上安装 bazel 和 tensorflow
【发布时间】:2016-04-12 14:39:02
【问题描述】:

我想从源代码安装 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/110https://github.com/tensorflow/tensorflow/issues/527

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

【问题讨论】:

  • 我猜你甚至没有安装 docker 对吧?询问管理员或使用 AWS 实例。
  • @fabrizioM 我认为管理员不愿意安装 docker。 Redhat 6.X 上的 Redhat 不支持 Docker。此外,我不确定 docker 将如何与扭矩(工作分配系统)相互作用。 AWS 不适合我。
  • 现在 1 年后,我正在尝试在 Redhat 6.9 上安装 Bazel(用于tenserflow)。同样的问题。

标签: compilation redhat glibc tensorflow bazel


【解决方案1】:

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

  1. 使用选项--disable-rpath 从源代码编译最新的 glibc、gcc 及其所有依赖项,以避免 glibc 路径被硬编码为系统默认值。不要将 glibc 直接添加到 LD_LIBRARY_PATH,否则包括 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}which python'

  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

【讨论】:

    【解决方案2】:

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

    我目前正在努力让这一切变得更容易。很抱歉弄得一团糟。

    【讨论】:

    • 更新版本是指 Bazel 0.1.2?我正在编译 bazel 0.1.1,因为只有 bazel 0.1.1 可以编译 tensorflow。在tensorflow github上,也有人提示Bazel 0.1.2无法编译tensorflow。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-05
    • 2018-01-31
    • 2016-03-08
    • 1970-01-01
    相关资源
    最近更新 更多