在构建不支持avx2的tensorflow v1.14.0时编译错误

使用Debian 10 Buster,Python v2.7。 我尝试构建不支持avx2的特定tensorflow v1.14.0,因为出现以下错误:

  

11月4日17:12:32 moodle37内核:[9773297.574293]陷阱:   python2.7 [4570]陷阱无效的操作码ip:7fb9b74bca59 sp:7ffdb7605e10   libtensorflow_framework.so.1 [7fb9b6d97000 + 18f8000]中的错误0:

1)我用git克隆了tensorflow

2)签出了v1.14.0。

>git status
HEAD detached at v1.14.0

3)

gcc -Q -march=native --help=target | grep march
  -march=                               nehalem

因此,CPU代号为nehalem。

4)我使用了./configure 带有构建选项:

-march=nehalem mavx -msse4.1 -msse4.2 -mpclmul -mpopcnt -maes -mno-avx2

5)已执行

bazel build //tensorflow/tools/pip_package:build_pip_package

但我遇到了构建错误:

ERROR: /root/inst/tensorflow_src/tensorflow/core/kernels/BUILD:3255:1: C++ compilation of rule '//tensorflow/core/kernels:matrix_square_root_op' failed (Exit 1)
gcc: fatal error: Killed signal terminated program cc1plus
compilation terminated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 18990.253s,Critical Path: 381.93s
INFO: 2372 processes: 2372 local.
FAILED: Build did NOT complete successfully

6)已执行

bazel build --verbose_failures //tensorflow/tools/pip_package:build_pip_package  

出现以下错误:

ERROR: /root/inst/tensorflow_src/tensorflow/core/kernels/BUILD:3255:1: C++ compilation of rule '//tensorflow/core/kernels:matrix_square_root_op' failed (Exit 1): gcc failed: error executing command
  (cd /root/.cache/bazel/_bazel_root/d7c6443e63bbc3c61de28c70992e7b9c/execroot/org_tensorflow && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/usr/bin/python \
    PYTHON_LIB_PATH=/usr/local/lib/python2.7/dist-packages \
    TF_CONFIGURE_IOS=0 \
    TF_DOWNLOAD_CLANG=0 \
    TF_NEED_CUDA=0 \
    TF_NEED_OPENCL_SYCL=0 \
    TF_NEED_ROCM=0 \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.d '-frandom-seed=bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.o' -fPIC -D__CLANG_SUPPORT_DYN_ANNOTATION__ -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=64' '-DEIGEN_HAS_TYPE_TRAITS=0' -DTF_USE_snAPPY -iquote . -iquote bazel-out/k8-py2-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-py2-opt/bin/external/com_google_absl -iquote external/eigen_archive -iquote bazel-out/k8-py2-opt/bin/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/k8-py2-opt/bin/external/local_config_sycl -iquote external/nsync -iquote bazel-out/k8-py2-opt/bin/external/nsync -iquote external/gif_archive -iquote bazel-out/k8-py2-opt/bin/external/gif_archive -iquote external/jpeg -iquote bazel-out/k8-py2-opt/bin/external/jpeg -iquote external/protobuf_archive -iquote bazel-out/k8-py2-opt/bin/external/protobuf_archive -iquote external/com_googlesource_code_re2 -iquote bazel-out/k8-py2-opt/bin/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/k8-py2-opt/bin/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/k8-py2-opt/bin/external/fft2d -iquote external/highwayhash -iquote bazel-out/k8-py2-opt/bin/external/highwayhash -iquote external/zlib_archive -iquote bazel-out/k8-py2-opt/bin/external/zlib_archive -isystem external/eigen_archive -isystem bazel-out/k8-py2-opt/bin/external/eigen_archive -isystem external/nsync/public -isystem bazel-out/k8-py2-opt/bin/external/nsync/public -isystem external/gif_archive/lib -isystem bazel-out/k8-py2-opt/bin/external/gif_archive/lib -isystem external/protobuf_archive/src -isystem bazel-out/k8-py2-opt/bin/external/protobuf_archive/src -isystem external/farmhash_archive/src -isystem bazel-out/k8-py2-opt/bin/external/farmhash_archive/src -isystem external/zlib_archive -isystem bazel-out/k8-py2-opt/bin/external/zlib_archive -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions '-ftemplate-depth=900' -msse3 -pthread -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/core/kernels/matrix_square_root_op.cc -o bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.o)
Execution platform: @bazel_tools//platforms:host_platform
gcc: fatal error: Killed signal terminated program cc1plus
compilation terminated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 3559.068s,Critical Path: 448.60s
INFO: 397 processes: 397 local.
FAILED: Build did NOT complete successfully

EDIT1:

191105 20:22:26.151:I 1354 [com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.start] starting local subprocess #314,argv: /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -D_FORTIFY_SOURCE=1 -DNDEBUG -ffunction-sections -fdata-sections -std=c++0x -MD -MF bazel-out/k8-py2-opt/bin/te...tin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" -c tensorflow/core/kernels/matrix_square_root_op.cc -o bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.o
191105 20:22:26.151:I 1354 [com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.stepLog] prefetching inputs for local execution (#314 Compiling tensorflow/core/kernels/matrix_square_root_op.cc)
191105 20:22:26.151:I 1354 [com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.setState] Step #314 time: 0.001 delta: 0.001 state: PARSING --> PREFETCHING_LOCAL_INPUTS
191105 20:22:26.152:I 1354 [com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.stepLog] running locally (#314 Compiling tensorflow/core/kernels/matrix_square_root_op.cc)
191105 20:22:26.152:I 1354 [com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.setState] Step #314 time: 0.002 delta: 0.001 state: PREFETCHING_LOCAL_INPUTS --> LOCAL_actION_RUNNING
191105 20:29:22.020:I 1354 [com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.setState] Step #314 time: 415.868 delta: 415.866 state: LOCAL_actION_RUNNING --> SUCCESS
191105 20:29:22.363:W 1354 [com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run] Aborting evaluation due to com.google.devtools.build.lib.skyframe.actionExecutionFunction$actionExecutionFunctionException: com.google.devtools.build.lib.actions.AlreadyReportedactionExecutionException: C++ compilation of rule '//tensorflow/core/kernels:matrix_square_root_op' failed (Exit 1): gcc failed: error executing command
  (cd /moodledata/inst/.cache/bazel/_bazel_root/ebeb582d6679e454bd341748991b8998/execroot/org_tensorflow && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/usr/bin/python \
    PYTHON_LIB_PATH=/usr/local/lib/python2.7/dist-packages \
    TF_CONFIGURE_IOS=0 \
    TF_DOWNLOAD_CLANG=0 \
    TF_NEED_CUDA=0 \
    TF_NEED_OPENCL_SYCL=0 \
    TF_NEED_ROCM=0 \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.d '-frandom-seed=bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.o' -fPIC -D__CLANG_SUPPORT_DYN_ANNOTATION__ -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=64' '-DEIGEN_HAS_TYPE_TRAITS=0' -DTF_USE_snAPPY -iquote . -iquote bazel-out/k8-py2-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-py2-opt/bin/external/com_google_absl -iquote external/eigen_archive -iquote bazel-out/k8-py2-opt/bin/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/k8-py2-opt/bin/external/local_config_sycl -iquote external/nsync -iquote bazel-out/k8-py2-opt/bin/external/nsync -iquote external/gif_archive -iquote bazel-out/k8-py2-opt/bin/external/gif_archive -iquote external/jpeg -iquote bazel-out/k8-py2-opt/bin/external/jpeg -iquote external/protobuf_archive -iquote bazel-out/k8-py2-opt/bin/external/protobuf_archive -iquote external/com_googlesource_code_re2 -iquote bazel-out/k8-py2-opt/bin/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/k8-py2-opt/bin/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/k8-py2-opt/bin/external/fft2d -iquote external/highwayhash -iquote bazel-out/k8-py2-opt/bin/external/highwayhash -iquote external/zlib_archive -iquote bazel-out/k8-py2-opt/bin/external/zlib_archive -isystem external/eigen_archive -isystem bazel-out/k8-py2-opt/bin/external/eigen_archive -isystem external/nsync/public -isystem bazel-out/k8-py2-opt/bin/external/nsync/public -isystem external/gif_archive/lib -isystem bazel-out/k8-py2-opt/bin/external/gif_archive/lib -isystem external/protobuf_archive/src -isystem bazel-out/k8-py2-opt/bin/external/protobuf_archive/src -isystem external/farmhash_archive/src -isystem bazel-out/k8-py2-opt/bin/external/farmhash_archive/src -isystem external/zlib_archive -isystem bazel-out/k8-py2-opt/bin/external/zlib_archive -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions '-ftemplate-depth=900' -msse3 -pthread -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/core/kernels/matrix_square_root_op.cc -o bazel-out/k8-py2-opt/bin/tensorflow/core/kernels/_objs/matrix_square_root_op/matrix_square_root_op.pic.o)
Execution platform: @bazel_tools//platforms:host_platform while evaluating actionLookupData{actionLookupKey=//tensorflow/core/kernels:matrix_square_root_op BuildConfigurationValue.Key[06916201e0a2e3a731dd7c8fca228a97] false,actionIndex=1}

我该如何解决?

-解决方案:

我有2 GB的虚拟机RAM。将RAM增加到8 GB后,构建成功完成。

adsli 回答:在构建不支持avx2的tensorflow v1.14.0时编译错误

即使在注释部分(感谢Laszlo和jdehesa)和Questoin中也提供了解决方案(答案部分),以获取社区的好处

尝试使用不带Bazel的{​​{1}}构建Tensorflow时,错误

AVX2 Support

Nov 4 17:12:32 moodle37 kernel: [9773297.574293] traps: python2.7[4570] trap invalid opcode ip:7fb9b74bca59 sp:7ffdb7605e10 error:0 in libtensorflow_framework.so.1[7fb9b6d97000+18f8000]

将通过以下方式解决:将计算机的RAM从2GB RAM增加到8GB

学习愉快!

本文链接:https://www.f2er.com/3147355.html

大家都在问