tensorflow: Tensorflow-2.3.0 build failed

System information

  • OS Platform and Distribution :Linux Ubuntu 16.04
  • TensorFlow installed from (source or binary): Source
  • TensorFlow version: 2.3.0
  • Python version: 3.8.5
  • Bazel version (if compiling from source): 3.1.0
  • GCC/Compiler version (if compiling from source): 5.4.0
  • CUDA/cuDNN version: Cuda10.0, cudnn 7.6.5.32
  • GPU model and memory: GTX1070 , 8G

Describe the problem Cannot build tensorflow

Tensorflow configured with cuda and tensorrt enabled

build with

bazel build --config=opt --config=cuda --copt=-mavx --copt=-mavx2 --copt=-msse4.1 --copt=-msse4.2 --copt=-mfma --copt=-mfpmath=both //tensorflow/tools/pip_package:build_pip_package 

build failed with these output

INFO: From ProtoCompile tensorflow/lite/toco/toco_flags.pb.h:
bazel-out/k8-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
ERROR: /home/bernard/opt/python38/tensorflow-2.3.0/tensorflow/core/kernels/BUILD:5123:1: C++ compilation of rule '//tensorflow/core/kernels:dilation_ops_gpu' failed (Exit 1)
external/com_google_absl/absl/time/internal/cctz/include/cctz/civil_time_detail.h: In function ‘constexpr absl::lts_2020_02_25::time_internal::cctz::detail::civil_day absl::lts_2020_02_25::time_internal::cctz::detail::next_weekday(absl::lts_2020_02_25::time_internal::cctz::detail::civil_day, absl::lts_2020_02_25::time_internal::cctz::detail::weekday)’:
external/com_google_absl/absl/time/internal/cctz/include/cctz/civil_time_detail.h:567:20: error: call to non-constexpr function ‘absl::lts_2020_02_25::time_internal::cctz::detail::civil_time<absl::lts_2020_02_25::time_internal::cctz::detail::day_tag> absl::lts_2020_02_25::time_internal::cctz::detail::operator+(absl::lts_2020_02_25::time_internal::cctz::detail::civil_time<absl::lts_2020_02_25::time_internal::cctz::detail::day_tag>, absl::lts_2020_02_25::time_internal::cctz::diff_t)’
           return cd + (j - i);
                    ^
external/com_google_absl/absl/time/internal/cctz/include/cctz/civil_time_detail.h: In function ‘constexpr absl::lts_2020_02_25::time_internal::cctz::detail::civil_day absl::lts_2020_02_25::time_internal::cctz::detail::prev_weekday(absl::lts_2020_02_25::time_internal::cctz::detail::civil_day, absl::lts_2020_02_25::time_internal::cctz::detail::weekday)’:
external/com_google_absl/absl/time/internal/cctz/include/cctz/civil_time_detail.h:587:20: error: call to non-constexpr function ‘absl::lts_2020_02_25::time_internal::cctz::detail::civil_time<absl::lts_2020_02_25::time_internal::cctz::detail::day_tag> absl::lts_2020_02_25::time_internal::cctz::detail::operator-(absl::lts_2020_02_25::time_internal::cctz::detail::civil_time<absl::lts_2020_02_25::time_internal::cctz::detail::day_tag>, absl::lts_2020_02_25::time_internal::cctz::diff_t)’
           return cd - (j - i);
                    ^
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: 1001.142s, Critical Path: 93.36s
INFO: 4993 processes: 4993 local.
FAILED: Build did NOT complete successfully

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 46 (25 by maintainers)

Most upvoted comments

I ended up adding

--- ./absl/time/internal/cctz/include/cctz/civil_time_detail.h	2020-08-06 01:33:56.005757145 +0200
+++ ./absl/time/internal/cctz/include/cctz/civil_time_detail.h	2020-08-06 01:33:35.460579387 +0200
@@ -23,7 +23,7 @@
 #include "absl/base/config.h"
 
 // Disable constexpr support unless we are in C++14 mode.
-#if __cpp_constexpr >= 201304 || (defined(_MSC_VER) && _MSC_VER >= 1910)
+#if (!defined(NO_CONSTEXPR_FOR_YOU) && __cpp_constexpr >= 201304) || (defined(_MSC_VER) && _MSC_VER >= 1910)
 #define CONSTEXPR_D constexpr  // data
 #define CONSTEXPR_F constexpr  // function
 #define CONSTEXPR_M constexpr  // member

at the beginning of <path_to_tensorflow>/third_party/com_google_absl_fix_mac_and_nvcc_build.patch

adding

build:opt --copt=-DNO_CONSTEXPR_FOR_YOU=1
build:opt --host_copt=-DNO_CONSTEXPR_FOR_YOU=1

in .bazelrc

Build completed successfully with bazel build --config=cuda --config=opt --config=v2 //tensorflow/tools/pip_package:build_pip_package

The patch being talked here is third_party/com_google_absl_fix_mac_and_nvcc_build.patch. This patch is already being used by TF here https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/workspace.bzl#L227. But we need to update it by adding the additional stuff mentioned https://github.com/mozilla/tensorflow/commit/6fad14b203093e7a19301c4ef51a87fce71e38cb#diff-18a66e25fbcbd72730332a799ddee2ec. And then add following two lines in .bazelrc file which is in tensorflow source code.

build:opt --copt=-DNO_CONSTEXPR_FOR_YOU=1
build:opt --host_copt=-DNO_CONSTEXPR_FOR_YOU=1

Please refer to this issue with same error and update us. [link]

@Saduf2019 Your two links are completely different issues.