tensorflow: Fail to build from source with gcc 7.3.1
Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): CentOS Linux release 7.5.1804 run as image under Singularity and/or Docker on Scientific Linux CERN SLC release 6.10 (Carbon)
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: NA
- TensorFlow installed from (source or binary): source
- TensorFlow version: master, on commit 8eb3cbcb423c4d840e88a910c5db47404207b8a4
- Python version: 2.7
- Installed using virtualenv? pip? conda?: manually compiling using bazel
- Bazel version (if compiling from source): 0.19.2
- GCC/Compiler version (if compiling from source): GCC 7.3.1
- CUDA/cuDNN version: NA
- GPU model and memory: NA
Describe the problem When compiling with gcc 7.3.1 rev 257125 (from gcc.gnu.org/svn) build chokes like this
ERROR: /tensorflow/tensorflow/core/kernels/BUILD:3206:1: C++ compilation of rule '//tensorflow/core/kernels:reduction_ops' failed (Exit 1)
In file included from external/eigen_archive/unsupported/Eigen/CXX11/Tensor:124:0,
from ./third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1,
from ./tensorflow/core/kernels/reduction_ops_common.h:27,
from tensorflow/core/kernels/reduction_ops_sum.cc:16:
external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h: In static member function 'static void std::_Function_handler<void(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Functor = Eigen::internal::TensorExecutor<Expression, Eigen::ThreadPoolDevice, Vectorizable, Tileable>::run(const Expression&, const Eigen::ThreadPoolDevice&) [with Expression = const Eigen::TensorAssignOp<Eigen::TensorMap<Eigen::Tensor<std::complex<float>, 0, 1, long int>, 16, Eigen::MakePointer>, const Eigen::TensorReductionOp<Eigen::internal::SumReducer<std::complex<float> >, const Eigen::IndexList<Eigen::type2index<0> >, const Eigen::TensorMap<Eigen::Tensor<const std::complex<float>, 1, 1, long int>, 16, Eigen::MakePointer>, Eigen::MakePointer> >; bool Vectorizable = true; bool Tileable = false]::<lambda(Eigen::internal::TensorExecutor<const Eigen::TensorAssignOp<Eigen::TensorMap<Eigen::Tensor<std::complex<float>, 0, 1, long int>, 16, Eigen::MakePointer>, const Eigen::TensorReductionOp<Eigen::internal::SumReducer<std::complex<float> >, const Eigen::IndexList<Eigen::type2index<0> >, const Eigen::TensorMap<Eigen::Tensor<const std::complex<float>, 1, 1, long int>, 16, Eigen::MakePointer>, Eigen::MakePointer> >, Eigen::ThreadPoolDevice, true, false>::StorageIndex, Eigen::internal::TensorExecutor<const Eigen::TensorAssignOp<Eigen::TensorMap<Eigen::Tensor<std::complex<float>, 0, 1, long int>, 16, Eigen::MakePointer>, const Eigen::TensorReductionOp<Eigen::internal::SumReducer<std::complex<float> >, const Eigen::IndexList<Eigen::type2index<0> >, const Eigen::TensorMap<Eigen::Tensor<const std::complex<float>, 1, 1, long int>, 16, Eigen::MakePointer>, Eigen::MakePointer> >, Eigen::ThreadPoolDevice, true, false>::StorageIndex)>; _ArgTypes = {long int, long int}]':
external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h:801:9: internal compiler error: in emit_move_insn, at expr.c:3698
values[i] = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce,
^~~~~~
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
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 74.923s, Critical Path: 51.44s
INFO: 2018 processes: 2018 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
exactly as described here: https://github.com/sylabs/singularity/issues/2536 When we changed the gcc to 8.2.0 tag 2d79333765b691fa27d82c1737cb2f00ec6a4499 (from https://github.com/gcc-mirror/gcc) and to 7.4.0 rev 268351 (from gcc.gnu.org/svn) the build went fine.
Provide the exact sequence of commands / steps that you executed before running into the problem
export CXX_OPT_FLAGS=-std=c++11
BAZEL_OPTS="--output_user_root ../build build -s --verbose_failures -c opt --cxxopt=${CXX_OPT_FLAGS}"
BAZEL_EXTRA_OPTS="--action_env PYTHONPATH=${PYTHON27PATH} --distinct_host_configuration=false"
bazel $BAZEL_OPTS $BAZEL_EXTRA_OPTS //tensorflow/tools/pip_package:build_pip_package
Any other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 25 (5 by maintainers)
Commits related to this issue
- tensorflow-native: workaround ice failure while building from source with gcc 7.3.1 The root cause is gcc ice issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89752 But we could not patch on nati... — committed to hongxu-jia/meta-tensorflow by hongxu-jia 4 years ago
- tensorflow-native: workaround ice failure while building from source with gcc 7.3.1 The root cause is gcc ice issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89752 But we could not patch on nati... — committed to hongxu-jia/meta-tensorflow by hongxu-jia 4 years ago
With this workaround, you can compile tensorflow with gcc 6.3
In external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h:801 (you can find the file in a subdirectory of ~/.cache/bazel )
replace
values[i] = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce, num_values_to_reduce, reducer);
by two instructions instead
Self::CoeffReturnType a = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce, num_values_to_reduce, reducer); values[i] = a;
Hello,
I can confirm TensorFlow cannot be built anymore on Debian Stable (Stretch) and Ubuntu LTS (Bionic) due to this “internal compiler error”:
Debian Stable comes with GCC 6.3 while Ubuntu LTS uses 7.3.
Regards,
I did apply the patch from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89752 and now the compiling works. This patch hasn’t been applied on branch of 7.x or lower version. Please do it manually, and re-compile gcc on arm.
On Wed, Jun 12, 2019 at 11:21 PM Mircho Rodozov notifications@github.com wrote:
It might because the usable memory of your system is too low compared to the number of parallel Bazel compilation tasks.
You could try setting it to a smaller value using:
bazel build --jobs 4 //...orbazel build --ram_utilization_factor 50.EDIT: wrong solution. Adding
--config=optseems to solve the problem with mygcc 6.3. Not sure why though.Try with gcc 5.4. It worked for me.
The workaround didn’t work for me.
I’m working from a stretch-based Docker instance, looking to install TF from source.
What worked for me was upgrading to gcc 8.3.0
Instructions
(for other Debian rooks out there like me)
First I added the following line to the bottom of my
/etc/apt/sources.list:Then I ran:
The default gcc for me was 6.3.0:
So I needed to update my gcc to point to the new one:
The default is now 8.3.0:
If I wanted to default to a different gcc version, I can now use:
References
We also run into the same problem trying to compile TensorFlow in our CentOS 7 with devtoolset-7. Does anyone have a solution for this?