Skip to content

Commit

Permalink
tensorflow: Fix compilation with numpy 1.19.x
Browse files Browse the repository at this point in the history
Numpy introduced a breaking API change in version 1.19.x, see [1].

There is a simple fix [2] available in the master branch.

[1]: tensorflow/tensorflow#40688
[2]: tensorflow/tensorflow@75ea0b3

(cherry picked from commit 8f5bfd6)
  • Loading branch information
avdv authored and danieldk committed Sep 21, 2020
1 parent 907dcba commit 2adb029
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkgs/development/python-modules/tensorflow/1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ let
})
./lift-gast-restriction.patch

(fetchpatch {
# fix compilation with numpy >= 1.19
name = "add-const-overload.patch";
url = "https://github.com/tensorflow/tensorflow/commit/75ea0b31477d6ba9e990e296bbbd8ca4e7eebadf.patch";
sha256 = "1xp1icacig0xm0nmb05sbrf4nw4xbln9fhc308birrv8286zx7wv";
})

# cuda 10.2 does not have "-bin2c-path" option anymore
# https://github.com/tensorflow/tensorflow/issues/34429
../cuda-10.2-no-bin2c-path.patch
Expand Down

2 comments on commit 2adb029

@minsky-1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. You were right. At this point changing the code worked. But, still, it can't make the TF pack. I got this error:

ERROR: /home/mnsky/tensorflow/tensorflow/BUILD:922:1: Executing genrule //tensorflow:tf_python_api_gen_v2 failed (Exit 1)
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/349bb11648069f0a9b13bec970961d74/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in
from tensorflow.python.tools.api.generator import doc_srcs
File "/root/.cache/bazel/_bazel_root/349bb11648069f0a9b13bec970961d74/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/init.py", line 28, in
import ctypes
File "/usr/local/lib/python3.7/ctypes/init.py", line 7, in
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
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/carlos/tensorflow/tensorflow/tools/pip_package/BUILD:62:1 Executing genrule //tensorflow:tf_python_api_gen_v2 failed (Exit 1)

I installed the "libffi-dev"... but it would not work. DO you think I have to reinstall python3.7? Thank you for your time.

@danieldk
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. You were right. At this point changing the code worked. But, still, it can't make the TF pack. I got this error:

ERROR: /home/mnsky/tensorflow/tensorflow/BUILD:922:1: Executing genrule //tensorflow:tf_python_api_gen_v2 failed (Exit 1)
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/349bb11648069f0a9b13bec970961d74/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in
from tensorflow.python.tools.api.generator import doc_srcs

I see that you are building Tensorflow outside Nix. This PR/backport was for the Nix package manager. General issues with building Tensorflow are probably better discussed upstream.

Please sign in to comment.