tensorflow: `TensorContractionThreadPool.h' file not found` when using `--copt=-march=native`

When trying to run

$ ./configure
........
$ bazel build --copt=-march=native -c opt //tensorflow/tools/pip_package:build_pip_package --verbose_failures

it fails with the ./third_party/eigen3/unsupported/Eigen/CXX11/FixedPoint:42:10: fatal error: 'src/Tensor/TensorContractionThreadPool.h' file not found error.

Similar problem was seen in #4680, #580,

I am on Mac OS X Sierra 10.12.2 with no CUDA and cuDNN installed. I am using virtual environment on Python 2.7

Here is the checked commit and bazel version

$ git rev-parse HEAD
ac28ae043df4bc6f112f964f6df22845b8a05390
$ bazel version
Build label: 0.4.3-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 22 15:20:15 2016 (1482420015)
Build timestamp: 1482420015
Build timestamp as int: 1482420015

This works fine:

$ git checkout remotes/origin/r0.12
$ ./configure # With defaults
.........
$ bazel build --copt=-march=native -c opt //tensorflow/tools/pip_package:build_pip_package --verbose_failures
# This finishes correctly

Here is the full terminal log when bazel is run on the master branch:

$ git checkout master
$ ./configure # With defaults
.........
$ bazel build --copt=-march=native -c opt //tensorflow/tools/pip_package:build_pip_package --verbose_failures
INFO: Found 1 target...
ERROR: /Users/zafar/GitHub/tensorflow/tensorflow/core/kernels/BUILD:856:1: C++ compilation of rule '//tensorflow/core/kernels:gather_functor' failed: cc_wrapper.sh failed: error executing command
  (cd /private/var/tmp/_bazel_zafar/c40dcca6773e4515fd11c724e0ebae51/execroot/tensorflow && \
  exec env - \
    PATH=/Users/zafar/.virtualenvs/tf-dev-env/bin:/Users/zafar/.rbenv/shims:/Users/zafar/.node/bin:/Users/zafar/bin:/Users/zafar/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/Library/TeX/texbin \
    TMPDIR=/var/folders/yx/nf9nvmpn4_79r7nbzkn8cz8h0000gn/T/ \
  external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-march=native' '-std=c++0x' -MD -MF bazel-out/local-opt/bin/tensorflow/core/kernels/_objs/gather_functor/tensorflow/core/kernels/gather_functor.pic.d '-frandom-seed=bazel-out/local-opt/bin/tensorflow/core/kernels/_objs/gather_functor/tensorflow/core/kernels/gather_functor.pic.o' -fPIC -DEIGEN_MPL2_ONLY -iquote . -iquote bazel-out/local-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/local-opt/genfiles/external/bazel_tools -iquote external/eigen_archive -iquote bazel-out/local-opt/genfiles/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/local-opt/genfiles/external/local_config_sycl -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/eigen_archive -isystem bazel-out/local-opt/genfiles/external/eigen_archive -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/core/kernels/gather_functor.cc -o bazel-out/local-opt/bin/tensorflow/core/kernels/_objs/gather_functor/tensorflow/core/kernels/gather_functor.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from tensorflow/core/kernels/gather_functor.cc:50:
In file included from ./tensorflow/core/kernels/gather_functor.h:22:
In file included from ./tensorflow/core/framework/type_traits.h:22:
In file included from ./tensorflow/core/framework/numeric_types.h:25:
./third_party/eigen3/unsupported/Eigen/CXX11/FixedPoint:42:10: fatal error: 'src/Tensor/TensorContractionThreadPool.h' file not found
#include "src/Tensor/TensorContractionThreadPool.h"
         ^
1 error generated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 34.692s, Critical Path: 25.26s

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

If it helps, I’ve “resolved” the issue for me by tinkering around a bit and adding the missing header:

  1. Add TensorContractionThreadPool.h from Eigen “itself” to TF’s third_party/eigen3/unsupported/Eigen/CXX11/src/Tensor directory (note that the leaf directory Tensor has to be created first).
  2. Update the hdrs parameter of the cc_library function in the Bazel third_party/eigen3/BUILD file to include the newly added file by inserting the following line in the list of files there: "unsupported/Eigen/CXX11/src/Tensor/TensorContractionThreadPool.h",

After that, my TF builds with AVX2 optimizations pass and I can nicely use a fully optimized, CUDA-enabled TF (so far, at least…).

But I have exactly zero idea if that’s indeed the right fix… YMMV 😉

@StanislawAntol I don’t think your error is related – you are running TF from the same directory where you cloned the repo. Try going to any other directory, the error will be different

@fnl I can get it to work by using the r0.12 branch, so there is no need for tinkering and manually placing the files. Also, r0.12 has no major differences with the master (ac28ae043df4bc6f112f964f6df22845b8a05390). The reason I opened an issue is because it might affect the future releases, and we need to find what caused it.