Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow-2.3.0 build failed #41926

Closed
beew opened this issue Jul 31, 2020 · 46 comments
Closed

Tensorflow-2.3.0 build failed #41926

beew opened this issue Jul 31, 2020 · 46 comments
Assignees
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower subtype: ubuntu/linux Ubuntu/Linux Build/Installation Issues type:build/install Build and install issues

Comments

@beew
Copy link

beew commented Jul 31, 2020

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
@beew beew added the type:build/install Build and install issues label Jul 31, 2020
@Saduf2019 Saduf2019 added the subtype: ubuntu/linux Ubuntu/Linux Build/Installation Issues label Jul 31, 2020
@Saduf2019
Copy link
Contributor

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

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Aug 3, 2020
@beew
Copy link
Author

beew commented Aug 3, 2020

@Saduf2019

Not work, updated setuptools to the latest version (49.2.1), failed again, similar but different error

Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/bernard/opt/python38/tensorflow-2.3.0/tensorflow/python/tools/BUILD:226:1 C++ compilation of rule '//tensorflow/core/kernels:matrix_diag_op_gpu' failed (Exit 1)
INFO: Elapsed time: 2415.388s, Critical Path: 105.97s
INFO: 7622 processes: 7622 local.
FAILED: Build did NOT complete successfully

Should add that I have the same setup with bazel 2.0 and was able to build tf 2.2.0 without a hitch.

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Aug 5, 2020
@lissyx
Copy link
Contributor

lissyx commented Aug 5, 2020

Facing the same issue on CI where we also use Ubuntu 16.04 + GCC 5.4.0

@lissyx
Copy link
Contributor

lissyx commented Aug 5, 2020

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

@Saduf2019 Your two links are completely different issues.

@lissyx
Copy link
Contributor

lissyx commented Aug 5, 2020

According to HowardHinnant/date#477 it might be because of GCC itself.

@beew
Copy link
Author

beew commented Aug 5, 2020

@lissyx

I have tried multiple versions of gcc but still not working.

I tried to compile with gcc-9.3.0 installed in custom location but bazel said

ERROR: /home/bernard/opt/python38/tensorflow-2.3.0/tensorflow/core/kernels/BUILD:1232:1: C++ compilation of rule '//tensorflow/core/kernels:quantize_and_dequantize_op_gpu' failed (Exit 1)
In file included from /home/bernard/opt/cuda-10.0/cuda/bin/..//include/cuda_runtime.h:83,
                 from <command-line>:
/home/bernard/opt/cuda-10.0/cuda/bin/..//include/crt/host_config.h:129:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!
  129 | #error -- unsupported GNU version! gcc versions later than 7 are not supported!
      |  ^~~~~
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/bernard/opt/python38/tensorflow-2.3.0/tensorflow/python/tools/BUILD:82:1 C++ compilation of rule '//tensorflow/core/kernels:quantize_and_dequantize_op_gpu' failed (Exit 1)


I then tried gcc-7.5 and it said libstdc++.so.6 is missing GLIBCXX_3.4.26 (which is supported for libstdc++.so.6 in gcc-9.3.0)

@lissyx
Copy link
Contributor

lissyx commented Aug 5, 2020

I have tried multiple versions of gcc but still not working.

Using backported gcc-6 from ubuntu toolchain team worked for me: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=xenial

Just install gcc-6, g++-6 and either setup alternatives for gcc/g++ or CC=gcc-6 CXX=g++-6 should do the trick.

@lissyx
Copy link
Contributor

lissyx commented Aug 5, 2020

@beew You can also take a look at the header, there is support for disabling constexpr in some cases, I might use that and add a hack.

@beew
Copy link
Author

beew commented Aug 6, 2020

@lissyx
Hi,

Compiling with gcc-6.5 works, however, update alternatives is not enough, I got the error

/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found 

So I had to make a conf file in /etc/ld.so.conf.d with /path/to/gcc-6.5.0/lib64 followed by sudo ldconfig

Build was successful, but I am wondering if it will have other side effects by leaving this version of libstdc++.so.6 in the ld path? (tensorflow 2.3 won't run without it)

Thanks

@Saduf2019
Copy link
Contributor

@beew
Please refer to these resolved issues for the above missing file error:
link link1 link2 link3 and update us.

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Aug 7, 2020
@lissyx
Copy link
Contributor

lissyx commented Aug 7, 2020

@Saduf2019 The issue is clearly just that this cannot build with GCC 5.4. I have been able to do so with a little nasty patch: mozilla@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec

This does had a define NO_CONSTEXPR_FOR_YOU that I can set at build time and leverage the ability to build this part without constexpr at all.

@lissyx
Copy link
Contributor

lissyx commented Aug 7, 2020

Build was successful, but I am wondering if it will have other side effects by leaving this version of libstdc++.so.6 in the ld path? (tensorflow 2.3 won't run without it)

That depends on your needs.

@beew
Copy link
Author

beew commented Aug 7, 2020

@lissyx

Build was successful, but I am wondering if it will have other side effects by leaving this version of libstdc++.so.6 in the ld path? (tensorflow 2.3 won't run without it)

That depends on your needs.

Hi, My question is really whether the presence of a higher libstdc++so.6 in the library path would interfere with projects compiled with a lower version. All the links provided by @Saduf2019 involve upgrading libstdc++so.6 one way or the other basically like what I have done, by making a config file in /etc/ld.so.conf.d, except I keep the older system version as well.

I could set LD_LIBRARY_PATH at runtime but it is kind of cumbersome (or by adding it to LD_LIBRARY_PATH in the script I invoke to launch python-3.8 but it has the same concern since I have compiled quite a few python packages from source) BTW setting LD_LIBRARY_PATH doesn't work for compile time since bazel couldn't find it, only adding to /etc/ld.so.conf.d works.

@Saduf2019 Saduf2019 removed the stat:awaiting response Status - Awaiting response from author label Aug 7, 2020
@Saduf2019 Saduf2019 assigned jvishnuvardhan and unassigned Saduf2019 Aug 7, 2020
@jvishnuvardhan jvishnuvardhan added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Aug 7, 2020
@npanpaliya
Copy link
Contributor

npanpaliya commented Aug 24, 2020

@Saduf2019 The issue is clearly just that this cannot build with GCC 5.4. I have been able to do so with a little nasty patch: mozilla@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec

This does had a define NO_CONSTEXPR_FOR_YOU that I can set at build time and leverage the ability to build this part without constexpr at all.

I've been facing the same error with gcc 5.4 but I can't update my gcc as anaconda doesn't have 6.x packages for gcc/gxx. I tried above mentioned patch as well as defined the macro NO_CONSTEXPR_FOR_YOU in bazelrc as below, still same error -

build:opt --copt=-DNO_CONSTEXPR_FOR_YOU=1
build --define=NO_CONSTEXPR_FOR_YOU=1

It looks like the way I've defined it isn't right. Could someone please help me define this macro?

@lissyx
Copy link
Contributor

lissyx commented Aug 24, 2020

@Saduf2019 The issue is clearly just that this cannot build with GCC 5.4. I have been able to do so with a little nasty patch: mozilla@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec
This does had a define NO_CONSTEXPR_FOR_YOU that I can set at build time and leverage the ability to build this part without constexpr at all.

I've been facing the same error with gcc 5.4 but I can't update my gcc as anaconda doesn't have 6.x packages for gcc/gxx. I tried above mentioned patch as well as defined the macro NO_CONSTEXPR_FOR_YOU in bazelrc as below, still same error -

build:opt --copt=-DNO_CONSTEXPR_FOR_YOU=1
build --define=NO_CONSTEXPR_FOR_YOU=1

It looks like the way I've defined it isn't right. Could someone please help me define this macro?

Have you applied the linked patch?

Once that's the case, --copt=-DNO_CONSTEXPR_FOR_YOU=1 should be enough.

@npanpaliya
Copy link
Contributor

Yes, I've it applied -

diff --git a/third_party/com_google_absl_fix_mac_and_nvcc_build.patch b/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
index 271e941..81c8e5d 100644
--- a/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
+++ b/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
@@ -1,3 +1,14 @@
+--- ./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
 --- ./absl/time/internal/cctz/BUILD.bazel      2019-09-23 13:20:52.000000000 -0700
 +++ ./absl/time/internal/cctz/BUILD.bazel.fixed        2019-09-23 13:20:48.000000000 -0700
 @@ -74,15 +74,6 @@
@@ -301,4 +312,3 @@
 +        .internal_compressed_tuple::template Storage<CompressedTuple, I>::get();
    }
  };

@lissyx
Copy link
Contributor

lissyx commented Aug 24, 2020

Well, it's working for us, I can't do more.

@npanpaliya
Copy link
Contributor

With same gcc 5.4?

@npanpaliya
Copy link
Contributor

Okay. Thanks.

@npanpaliya
Copy link
Contributor

npanpaliya commented Aug 25, 2020

@lissyx - The macro setting mentioned in bazelrc worked for cpu builds but not for gpu build. It looks like the same macro has to be defined for nvcc too. I've tried this build:cuda --define=-DNO_CONSTEXPR_FOR_YOU=1 but it didn't work. Could you please help me set the same macro for cu.cc files?

@lissyx
Copy link
Contributor

lissyx commented Aug 25, 2020

@lissyx - The macro setting mentioned in bazelrc worked for cpu builds but not for gpu build. It looks like the same macro has to be defined for nvcc too. I've tried this build:cuda --define=-DNO_CONSTEXPR_FOR_YOU=1 but it didn't work. Could you please help me set the same macro for cu.cc files?

no, I can't help you. again, what I shared is what we use and it works everywhere.

@gunan
Copy link
Contributor

gunan commented Aug 26, 2020

The build is also working fine for us. I cannot reproduce the issue.
I would recommend reaching out to absl team for support.

Since we cannot reproduce the problem, one way we can help is if you can create a docker container where we can reproduce the problem, we may be able to debug and help.

@gunan gunan closed this as completed Aug 26, 2020
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@lissyx
Copy link
Contributor

lissyx commented Aug 26, 2020

The build is also working fine for us. I cannot reproduce the issue.

@gunan Have you tried on a distro using GCC 5.4 ?

@npanpaliya
Copy link
Contributor

Thanks a lot everyone. I was able to fix the problem using GCC 5.4 by adding another line in bazelrc for setting --host_copt too as below.

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

@yuzehh
Copy link

yuzehh commented Sep 21, 2020

Thanks a lot everyone. I was able to fix the problem using GCC 5.4 by adding another line in bazelrc for setting --host_copt too as below.

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

Hi, I'm really confused about how to use the patch and where to set these two lines you mentioned. Could you please explain more details? Thanks a lot!

@npanpaliya
Copy link
Contributor

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 mozilla@6fad14b#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

@yuzehh
Copy link

yuzehh commented Sep 21, 2020

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 mozilla@6fad14b#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

Thanks for your reply. What's the specific command line to add the additional stuff? Could you please tell me the detailed steps? I'm not familiar with the operations of patches. Thanks again!

@npanpaliya
Copy link
Contributor

npanpaliya commented Sep 22, 2020

@Yuze-HE
To update the existing patch, I did following -

  1. Download the abseil code mentioned in tensorflow/workspace.bzl at here https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/workspace.bzl#L232.
    wget https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz
  2. Extract the downloaded tar
    tar -xvf df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz
  3. Create a copy of this extracted tar as abseil_orig
  4. Go to the extracted directory and apply the original patch which is https://github.com/tensorflow/tensorflow/blob/v2.3.0/third_party/com_google_absl_fix_mac_and_nvcc_build.patch using below command -
    patch -p1 < <path_to_tensorflow>/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
  5. Hand edit the files mentioned here mozilla@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec.
  6. Take the diff of abseil_org with this abseil directory which has got modified files because of above two steps, using below command -
    diff -Naur abseil_org abseil > <path_to_tensorflow>/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
  7. Now, restart the TF build after updating .bazelrc with the two lines mentioned in my previous comment.

@yuzehh
Copy link

yuzehh commented Sep 24, 2020

@Yuze-HE
To update the existing patch, I did following -

  1. Download the abseil code mentioned in tensorflow/workspace.bzl at here https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/workspace.bzl#L232.
    wget https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz
  2. Extract the downloaded tar
    tar -xvf df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz
  3. Create a copy of this extracted tar as abseil_orig
  4. Go to the extracted directory and apply the original patch which is https://github.com/tensorflow/tensorflow/blob/v2.3.0/third_party/com_google_absl_fix_mac_and_nvcc_build.patch using below command -
    patch -p1 < <path_to_tensorflow>/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
  5. Hand edit the files mentioned here mozilla@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec.
  6. Take the diff of abseil_org with this abseil directory which has got modified files because of above two steps, using below command -
    diff -Naur abseil_org abseil > <path_to_tensorflow>/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
  7. Now, restart the TF build after updating .bazelrc with the two lines mentioned in my previous comment.

Thank you very much!

@AndreyOrb
Copy link

AndreyOrb commented Oct 5, 2020

Is it something that will be integrated into TF build in some reasonable time period?

@AndreyOrb
Copy link

@npanpaliya "edit the files mentioned here mozilla/tensorflow@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec."
What files do you mean? Or do I have to apply this patch as well?

@npanpaliya
Copy link
Contributor

Editing the files in absl as per the changes mentioned at mozilla/tensorflow@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec.
Then create a single patch of existing content of https://github.com/tensorflow/tensorflow/blob/v2.3.0/third_party/com_google_absl_fix_mac_and_nvcc_build.patch and changes in mozilla/tensorflow in that commit.

Regarding TF including these changes - I think it will probably not included by TF as these changes are needed to get TF built with older gcc 5.4. But TF community can comment more on this.

@AndreyOrb
Copy link

Same issue with
TF 2.4.0-rc3
Python 3.6.9
GPU: Tesla T4 | NVIDIA driver: 455.45.01 | CUDA: 10.1.243 | CUDNN: 7.6.4
Bazel 3.1.0

@AndreyOrb
Copy link

@AndreyOrb
Copy link

Editing the files in absl as per the changes mentioned at mozilla/tensorflow@6fad14b#diff-18a66e25fbcbd72730332a799ddee2ec.
Then create a single patch of existing content of https://github.com/tensorflow/tensorflow/blob/v2.3.0/third_party/com_google_absl_fix_mac_and_nvcc_build.patch and changes in mozilla/tensorflow in that commit.

Regarding TF including these changes - I think it will probably not included by TF as these changes are needed to get TF built with older gcc 5.4. But TF community can comment more on this.

I have 3 folder:

  1. Original absl in TF folder
  2. abseil-cpp-df3ea785d8c30a9503321a3d35ee7d35808f190d (extracted from tar.gz)
  3. abseil_orig (copied abseil-cpp-df3ea785d8c30a9503321a3d35ee7d35808f190d folder)

I applied <path_to_tensorflow>/third_party/com_google_absl_fix_mac_and_nvcc_build.patch on 2nd folder.

Now you say to hand edit files from mozilla patch.
I understand that there are 2 files to be edited:
1)./absl/time/internal/cctz/include/cctz/civil_time_detail.h - it will add NO_CONSTEXPR_FOR_YOU flag
2) ./absl/time/internal/cctz/BUILD.bazel.fixed - I don't see it in any folder. What should I do here?

@AndreyOrb
Copy link

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

@gmt710
Copy link

gmt710 commented Dec 8, 2020

Hello, I followed your steps to compile tensorflow2.3.0, but it got this error:

./tensorflow/stream_executor/lib/statusor_internals.h:165:76: error: invalid static_cast from type 'const Status {aka const tensorflow::Status}' to type 'stream_executor::port::Status& {aka tensorflow::Status&}'
./tensorflow/stream_executor/lib/statusor_internals.h: In instantiation of 'bool stream_executor::port::internal_statusor::StatusOrData<T>::ok() const [with T = std::unique_ptr<stream_executor::dnn::RnnDescriptor>]':

My enviroment:

ubuntu16.04
cuda9.0
gcc5.4.0
tensorflow2.3.0

It's so wired. I have no idea about how to correct this ?
would you mind giving me some suggestion ?
Thanks !

@AndreyOrb
Copy link

@gmt710 I think your exception is not related to this issue.
Probably: #20764

@gmt710
Copy link

gmt710 commented Dec 8, 2020

Yes, but #20764 is not solved.

@ssrokyz
Copy link

ssrokyz commented Apr 2, 2021

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

worked for me
cuda 10.2, tensorflow 2.4.1, centos 7

@gmt710
Copy link

gmt710 commented Apr 2, 2021

wow, it's a good idea.
But I only can use cuda9.0.

@gmt710
Copy link

gmt710 commented Apr 2, 2021

cuda10.2
I've installed tensorflow yet and do not need build tensorflow.

@njzjz
Copy link
Contributor

njzjz commented Jul 25, 2021

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

In v2.5, the bug still exists, and com_google_absl_fix_mac_and_nvcc_build.patch has been moved to tensorflow/third_party/absl

@Zhaoyilunnn
Copy link

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 mozilla@6fad14b#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

Thanks, but I applied this patch and added the two lines and still got the same error.. I checked the downloaded absl code and I am sure the patch is applied.

// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   https://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

#ifndef ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_DETAIL_H_
#define ABSL_TIME_INTERNAL_CCTZ_CIVIL_TIME_DETAIL_H_

#include <cstdint>
#include <limits>
#include <ostream>
#include <type_traits>

#include "absl/base/config.h"

// Disable constexpr support unless we are in C++14 mode.
#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
#else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower subtype: ubuntu/linux Ubuntu/Linux Build/Installation Issues type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests