Building TensorFlow from source on Ubuntu 16.04 w/

2019-05-10 08:14发布

问题:

I'm on Ubuntu 16.04 and am trying to build TensorFlow with GPU support from source according to this. Everything works fine until the "Build TensorFlow" step, in which I execute:

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

The compilation hits an error with output:

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.

My suspicion is that the error has something to do with anaconda since bazel seems to be looking for libstdc++.so from within ~/anaconda2/lib.

回答1:

This command seemed to fix my problem:

conda install libgcc

from here.



回答2:

EDIT : Feynman27's solution seems cleaner, try it first.

Had the same issue. These steps have solved it for me (root, add sudo when needed):

  1. Get the newest libstdc++ 6 available (MAY NOT BE REQUIRED):

    add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get upgrade

  2. Update the symlinks in ananconda, I did it in my python2 env in anaconda, maybe you need to do it in ~/anaconda/lib directly:

    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