感谢支持
我们一直在努力

TensorFlow编译过程中遇到的问题及解决方案

最近一直尝试使用TensorFlow源码进行编译,在编译过程中遇到一个Status 4的错误码。 github问题链接

其完整错误日志如下:

ERROR: /home/wangbing/Git/tensorflow/tensorflow/core/kernels/BUILD:297:1: C++ compilation of rule '//tensorflow/core/kernels:mirror_pad_op' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command 
  (cd /home/wangbing/.cache/bazel/_bazel_wangbing/ab8decc7da56ae5392500261af1cc855/tensorflow && \
  exec env - \
    PATH=/home/wangbing/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/wangbing/bin \
  third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++11' -iquote . -iquote bazel-out/local_linux-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/local_linux-opt/genfiles/external/bazel_tools -iquote external/farmhash_archive -iquote bazel-out/local_linux-opt/genfiles/external/farmhash_archive -iquote external/jpeg_archive -iquote bazel-out/local_linux-opt/genfiles/external/jpeg_archive -iquote external/png_archive -iquote bazel-out/local_linux-opt/genfiles/external/png_archive -iquote external/re2 -iquote bazel-out/local_linux-opt/genfiles/external/re2 -iquote external/eigen_archive -iquote bazel-out/local_linux-opt/genfiles/external/eigen_archive -isystem google/protobuf/src -isystem bazel-out/local_linux-opt/genfiles/google/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 -isystem bazel-out/local_linux-opt/genfiles/external/farmhash_archive/farmhash-34c13ddfab0e35422f4c3979f360635a8c050260 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_linux-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_linux-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_linux-opt/genfiles/external/re2 -isystem third_party/eigen3 -isystem bazel-out/local_linux-opt/genfiles/third_party/eigen3 -isystem external/eigen_archive/eigen-eigen-a5e9085a94e8 -isystem bazel-out/local_linux-opt/genfiles/external/eigen_archive/eigen-eigen-a5e9085a94e8 -isystem third_party/gpus/cuda/include -isystem bazel-out/local_linux-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/gpus/cuda -isystem bazel-out/local_linux-opt/genfiles/third_party/gpus/cuda -fno-exceptions -DEIGEN_AVOID_STL_ARRAY -DTENSORFLOW_USE_EIGEN_THREADPOOL '-DGOOGLE_CUDA=1' -pthread '-DGOOGLE_CUDA=1' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -fno-canonical-system-headers '-frandom-seed=bazel-out/local_linux-opt/bin/tensorflow/core/kernels/_objs/mirror_pad_op/tensorflow/core/kernels/mirror_pad_op.o' -MD -MF bazel-out/local_linux-opt/bin/tensorflow/core/kernels/_objs/mirror_pad_op/tensorflow/core/kernels/mirror_pad_op.d -c tensorflow/core/kernels/mirror_pad_op.cc -o bazel-out/local_linux-opt/bin/tensorflow/core/kernels/_objs/mirror_pad_op/tensorflow/core/kernels/mirror_pad_op.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 4.
gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.

看到该错误的第一眼一直以为是由exec env - 导致的终端退出,在研究exec 命令上卡了半天,后来手动执行该命令是可以成功运行的,说明命令本身没有什么问题。
后来在GitHub上偶然发现了项目本身的成员提到status 4 是内存不足的问题,只需要增加swap空间即可。
该问题顺利解决。
Ubuntu下增加swap空间的命令如下:

# 生成swap镜像文件
sudo dd if=/dev/zero of=/mnt/512Mb.swap bs=1M count=512
# 对该镜像文件格式化
sudo mkswap /mnt/512Mb.swap
# 挂载该镜像文件 
sudo swapon /mnt/512Mb.swap

至此,使用free -m 即可查看到swap空间已经增加成功。

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-07/133216.htm

赞(0) 打赏
转载请注明出处:服务器评测 » TensorFlow编译过程中遇到的问题及解决方案
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏