GCC compilation error while building tensorflow using docker on mac(host) running ubuntu

System information

  • OS Platform: host: mac 14.10
  • docker image: tensorflow/tensorflow:latest-devel
  • TensorFlow version: 2.2
  • Python version: 3.6.9
  • building tensorflow from source using docker on mac with ubuntu in docker image
  • Bazel version (if compiling from source): 3.0.0
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: NONE ( cpu only build)
  • GPU model and memory: NONE

the problem

ERROR: /tensorflow_src/tensorflow/core/BUILD:2193:1: C++ compilation of rule '//tensorflow/core:framework_internal_impl' failed (Exit 4): gcc failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/43801f1e35f242fb634ebbc6079cf6c5/execroot/org_tensorflow && 
  exec env - 
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
    PWD=/proc/self/cwd 

  /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-opt-exec-50AE0418/bin/tensorflow/core/_objs/framework_internal_impl/batch_util.pic.d '-frandom-seed=bazel-out/k8-opt-exec-50AE0418/bin/tensorflow/core/_objs/framework_internal_impl/batch_util.pic.o' -fPIC -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=64' '-DEIGEN_HAS_TYPE_TRAITS=0' -DHAVE_SYS_UIO_H -DTF_USE_SNAPPY -D__CLANG_SUPPORT_DYN_ANNOTATION__ -iquote . -iquote bazel-out/k8-opt-exec-50AE0418/bin -iquote external/com_google_protobuf -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf -iquote external/com_google_absl -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_absl -iquote external/nsync -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/nsync -iquote external/eigen_archive -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/local_config_sycl -iquote external/gif -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/gif -iquote external/libjpeg_turbo -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo -iquote external/com_googlesource_code_re2 -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/fft2d -iquote external/highwayhash -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/highwayhash -iquote external/zlib -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/zlib -iquote external/double_conversion -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/double_conversion -iquote external/snappy -iquote bazel-out/k8-opt-exec-50AE0418/bin/external/snappy -isystem external/com_google_protobuf/src -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/src -isystem external/nsync/public -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/nsync/public -isystem external/eigen_archive -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/eigen_archive -isystem external/gif -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/gif -isystem external/farmhash_archive/src -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/farmhash_archive/src -isystem external/zlib -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/zlib -isystem external/double_conversion -isystem bazel-out/k8-opt-exec-50AE0418/bin/external/double_conversion -g0 '-march=native' -g0 '-std=c++14' -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare '-ftemplate-depth=900' -fno-exceptions '-DTENSORFLOW_USE_XLA=1' -msse3 -pthread '-DTENSORFLOW_USE_XLA=1' -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/core/util/batch_util.cc -o bazel-out/k8-opt-exec-50AE0418/bin/tensorflow/core/_objs/framework_internal_impl/batch_util.pic.o)
Execution platform: @local_execution_config_platform//:platform
In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/FixedPoint:41:0,
                 from ./tensorflow/core/framework/numeric_types.h:24,
                 from ./tensorflow/core/framework/allocator.h:26,
                 from ./tensorflow/core/framework/tensor.h:23,
                 from ./tensorflow/core/util/batch_util.h:18,
                 from tensorflow/core/util/batch_util.cc:16:

./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:30:41: warning: ignoring attributes on template argument '__m256i {aka __vector(4) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m256i, 20> Packet32q8i;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:31:41: warning: ignoring attributes on template argument '__m256i {aka __vector(4) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m256i, 21> Packet16q16i;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:32:41: warning: ignoring attributes on template argument '__m256i {aka __vector(4) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m256i, 22> Packet32q8u;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:33:41: warning: ignoring attributes on template argument '__m128i {aka __vector(2) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m128i, 23> Packet16q8i;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:34:41: warning: ignoring attributes on template argument '__m128i {aka __vector(2) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m128i, 25> Packet16q8u;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:35:41: warning: ignoring attributes on template argument '__m128i {aka __vector(2) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m128i, 26> Packet8q16i;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:36:41: warning: ignoring attributes on template argument '__m256i {aka __vector(4) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m256i, 27> Packet8q32i;
                                         ^
./third_party/eigen3/unsupported/Eigen/CXX11/src/FixedPoint/PacketMathAVX2.h:37:41: warning: ignoring attributes on template argument '__m128i {aka __vector(2) long long int}' [-Wignored-attributes]
 typedef eigen_packet_wrapper<__m128i, 28> Packet4q32i;
                                         ^
gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 1314.325s, Critical Path: 521.70s
INFO: 469 processes: 469 local.
FAILED: Build did NOT complete successfully
  • I am trying to build tensorflow from source to enable the AVX and FMA instruction. i followed the exact set of instructions inorder to start building. As given here i am building the cpu only version.
  • Since i am building from the latest one, I should be building from master branch. so I initiated using the below command:

bazel build --config=opt --local_ram_resources=4096 --verbose_failures //tensorflow/tools/pip_package:build_pip_packag

  • after this the analysis phase was done. The error occurred during compilation.

unable to diagnose the error. Please help

Source: StackOverflow