我使用 Ubuntu 15.10。目前,我正在按照说明从源代码构建 TensorFlow这里。
我的安装成功了,只剩下最后一步,“使用 GPU 支持构建你的目标”。
当我运行时bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainer --verbose_failures
,我看到以下输出:
INFO: Found 1 target...
ERROR: /home/me/tensorflow/tensorflow/cc/BUILD:28:1: Linking of rule '//tensorflow/cc:ops/nn_ops_gen_cc' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command
(cd /home/me/.cache/bazel/_bazel_me/38a03c514c8dc954778fc9a555bce3de/tensorflow && \
exec env - \
third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -o bazel-out/host/bin/tensorflow/cc/ops/nn_ops_gen_cc '-Wl,-rpath,$ORIGIN/../../../_solib_local/_U_S_Sthird_Uparty_Sgpus_Scuda_Ccudart___Uthird_Uparty_Sgpus_Scuda_Slib64' -Lbazel-out/host/bin/_solib_local/_U_S_Sthird_Uparty_Sgpus_Scuda_Ccudart___Uthird_Uparty_Sgpus_Scuda_Slib64 bazel-out/host/bin/tensorflow/cc/libcc_op_gen_main.a -Wl,-whole-archive bazel-out/host/bin/tensorflow/core/libnn_ops_op_lib.lo -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/host/bin/tensorflow/core/libframework_internal.lo -Wl,-no-whole-archive bazel-out/host/bin/tensorflow/core/liblib_internal.a bazel-out/host/bin/external/jpeg_archive/libjpeg.a bazel-out/host/bin/external/png_archive/libpng.a bazel-out/host/bin/external/re2/libre2.a bazel-out/host/bin/tensorflow/core/libprotos_all_cc.a bazel-out/host/bin/google/protobuf/libprotobuf.a bazel-out/host/bin/google/protobuf/libprotobuf_lite.a bazel-out/host/bin/_solib_local/_U_S_Sthird_Uparty_Sgpus_Scuda_Ccudart___Uthird_Uparty_Sgpus_Scuda_Slib64/libcudart.so.7.5 -lm -ldl -lm -ldl -lz -pthread -lpthread -Wl,-rpath,third_party/gpus/cuda/lib64 -lstdc++ -B/usr/bin/ -pie -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,-S -Wl,--gc-sections): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: crosstool_wrapper_driver_is_not_gcc failed: error executing command
(cd /home/me/.cache/bazel/_bazel_me/38a03c514c8dc954778fc9a555bce3de/tensorflow && \
exec env - \
third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -o bazel-out/host/bin/tensorflow/cc/ops/nn_ops_gen_cc '-Wl,-rpath,$ORIGIN/../../../_solib_local/_U_S_Sthird_Uparty_Sgpus_Scuda_Ccudart___Uthird_Uparty_Sgpus_Scuda_Slib64' -Lbazel-out/host/bin/_solib_local/_U_S_Sthird_Uparty_Sgpus_Scuda_Ccudart___Uthird_Uparty_Sgpus_Scuda_Slib64 bazel-out/host/bin/tensorflow/cc/libcc_op_gen_main.a -Wl,-whole-archive bazel-out/host/bin/tensorflow/core/libnn_ops_op_lib.lo -Wl,-no-whole-archive -Wl,-whole-archive bazel-out/host/bin/tensorflow/core/libframework_internal.lo -Wl,-no-whole-archive bazel-out/host/bin/tensorflow/core/liblib_internal.a bazel-out/host/bin/external/jpeg_archive/libjpeg.a bazel-out/host/bin/external/png_archive/libpng.a bazel-out/host/bin/external/re2/libre2.a bazel-out/host/bin/tensorflow/core/libprotos_all_cc.a bazel-out/host/bin/google/protobuf/libprotobuf.a bazel-out/host/bin/google/protobuf/libprotobuf_lite.a bazel-out/host/bin/_solib_local/_U_S_Sthird_Uparty_Sgpus_Scuda_Ccudart___Uthird_Uparty_Sgpus_Scuda_Slib64/libcudart.so.7.5 -lm -ldl -lm -ldl -lz -pthread -lpthread -Wl,-rpath,third_party/gpus/cuda/lib64 -lstdc++ -B/usr/bin/ -pie -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,-S -Wl,--gc-sections): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
Target //tensorflow/cc:tutorials_example_trainer failed to build
INFO: Elapsed time: 0.348s, Critical Path: 0.20s
主要的错误似乎是Linking of rule '//tensorflow/cc:ops/nn_ops_gen_cc' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command
。
编辑:
以下是我看到的另一条错误消息:
INFO: Found 1 target...
ERROR: /home/me/tensorflow/tensorflow/core/kernels/BUILD:235:1: error while parsing .d file: /home/miao_gambolputtymeensorflow/bazel-out/local_linux-opt/bin/tensorflow/core/kernels/_objs/constant_op_gpu/tensorflow/core/kernels/constant_op_gpu.cu.d (No such file or directory).
nvcc warning : option '--relaxed-constexpr' has been deprecated and replaced by option '--expt-relaxed-constexpr'.
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
Target //tensorflow/cc:tutorials_example_trainer failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.233s, Critical Path: 0.10s
有什么建议吗?
答案1
仔细阅读错误消息可以发现以下几行:
/usr/bin/ld: cannot find -lstdc++
和
cc: error trying to exec 'cc1plus': execvp: No such file or directory
在我的系统上(YMMV)libstdc++
由软件包提供libstdc++6-4.6-dev
,并由cc1plus
提供g++-4.8
。您需要安装标准 C++ 库和g++
适合您环境的正确版本的。