使用 GPU 在 Ubuntu 16.04 上从源代码构建 TensorFlow:未找到“GLIBCXX_3.4.20”
Building TensorFlow from source on Ubuntu 16.04 w/ GPU: `GLIBCXX_3.4.20' not found
我在 Ubuntu 16.04 上,我正在尝试根据 this 从源代码构建具有 GPU 支持的 TensorFlow。一切正常,直到我执行的 "Build TensorFlow" 步骤:
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
编译遇到错误输出:
ERROR: /home/thomas/tensorflow/tensorflow/core/BUILD:978:28: Executing genrule //tensorflow/core:proto_text_srcs_all failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions: /home/thomas/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions)
bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions: /home/thomas/anaconda2/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions)
bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions: /home/thomas/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions)
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
我怀疑这个错误与 anaconda 有关,因为 bazel 似乎正在从 ~/anaconda2/lib 中寻找 libstdc++.so。
编辑:Feynman27 的解决方案似乎更清晰,请先尝试。
有同样的问题。这些步骤已经为我解决了(root,需要时添加 sudo):
获取可用的最新 libstdc++ 6(可能不需要):
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
apt-get upgrade
更新 ananconda 中的符号链接,我在 anaconda 中的 python2 env 中完成,也许您需要直接在 ~/anaconda/lib 中完成:
cd ~/anaconda2/envs/python2/lib
mv libstdc++.so libstdc++.so.backup
mv libstdc++.so.6 libstdc++.so.6.backup
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
这个命令似乎解决了我的问题:
conda install libgcc
来自 here.
我在 Ubuntu 16.04 上,我正在尝试根据 this 从源代码构建具有 GPU 支持的 TensorFlow。一切正常,直到我执行的 "Build TensorFlow" 步骤:
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
编译遇到错误输出:
ERROR: /home/thomas/tensorflow/tensorflow/core/BUILD:978:28: Executing genrule //tensorflow/core:proto_text_srcs_all failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions: /home/thomas/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions)
bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions: /home/thomas/anaconda2/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions)
bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions: /home/thomas/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by bazel-out/host/bin/tensorflow/tools/proto_text/gen_proto_text_functions)
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
我怀疑这个错误与 anaconda 有关,因为 bazel 似乎正在从 ~/anaconda2/lib 中寻找 libstdc++.so。
编辑:Feynman27 的解决方案似乎更清晰,请先尝试。
有同样的问题。这些步骤已经为我解决了(root,需要时添加 sudo):
获取可用的最新 libstdc++ 6(可能不需要):
add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get upgrade
更新 ananconda 中的符号链接,我在 anaconda 中的 python2 env 中完成,也许您需要直接在 ~/anaconda/lib 中完成:
cd ~/anaconda2/envs/python2/lib mv libstdc++.so libstdc++.so.backup mv libstdc++.so.6 libstdc++.so.6.backup ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 libstdc++.so.6
这个命令似乎解决了我的问题:
conda install libgcc
来自 here.