Skip to content

python310Packages.tensorflow: 2.11.1 -> 2.13.0 - #254362

Closed
GaetanLepage wants to merge 3 commits into
NixOS:masterfrom
GaetanLepage:tensorflow-update
Closed

GaetanLepage wants to merge 3 commits into
NixOS:masterfrom
GaetanLepage:tensorflow-update

Conversation

@GaetanLepage

Copy link
Copy Markdown
Contributor

Description of changes

This is an attempt at updating tensorflow (currently broken and vulnerable) to the latest version.
Changelog: https://github.com/tensorflow/tensorflow/releases/tag/v2.13.0

This PR also updates tensorboard and tensorboard-data-server.

cc @abbradar

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@GaetanLepage
GaetanLepage requested a review from vcunat September 10, 2023 09:41
@github-actions github-actions Bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Sep 10, 2023
@GaetanLepage
GaetanLepage marked this pull request as draft September 10, 2023 09:45
@GaetanLepage

Copy link
Copy Markdown
Contributor Author

Currently, I am facing this error:

ERROR: /build/source/tensorflow/tsl/profiler/utils/BUILD:88:11: Compiling tensorflow/tsl/profiler/utils/tf_op_utils.cc [for host] failed: undeclared inclusion(s) in rule '//tensorfw/
this rule is missing dependency declarations for the following files included by 'tensorflow/tsl/profiler/utils/tf_op_utils.cc':
  'external/com_google_absl/absl/types/optional.h'
  'external/com_google_absl/absl/utility/utility.h'
INFO: Elapsed time: 218.790s, Critical Path: 78.82s
INFO: 2555 processes: 634 internal, 1921 local.

@doronbehar

Copy link
Copy Markdown
Contributor

I have no experience with these packages, so besides giving a 👍 for the changes (which currently look good) and run a nixpkgs-review I can't help much. Feel free to cc me when this is ready.

@GaetanLepage GaetanLepage changed the title Tensorflow update python3Packages.tensorflow: 2.11.1 -> 2.13.0 Sep 10, 2023
@GaetanLepage GaetanLepage changed the title python3Packages.tensorflow: 2.11.1 -> 2.13.0 python310Packages.tensorflow: 2.11.1 -> 2.13.0 Sep 10, 2023

@natsukium natsukium left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found out that we need to disable the following system libs.

diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix
index 348f5197a9d6..816c96ccd2a0 100644
--- a/pkgs/development/python-modules/tensorflow/default.nix
+++ b/pkgs/development/python-modules/tensorflow/default.nix
@@ -261,22 +261,26 @@ let
     # list of valid syslibs in
     # https://github.com/tensorflow/tensorflow/blob/master/third_party/systemlibs/syslibs_configure.bzl
     TF_SYSTEM_LIBS = lib.concatStringsSep "," ([
-      "absl_py"
+      # ERROR: no such target '@absl_py//absl/flags:argparse_flags'
+      # "absl_py"
       "astor_archive"
       "astunparse_archive"
       "boringssl"
       # Not packaged in nixpkgs
-      # "com_github_googleapis_googleapis"
       # "com_github_googlecloudplatform_google_cloud_cpp"
-      "com_google_protobuf"
+      # ERROR: no such target '@com_google_protobuf//:well_known_types_py_pb2_genproto'
+      # https://github.com/tensorflow/tensorflow/issues/60667
+      # "com_google_protobuf"
+      # ERROR: no such target '@com_google_absl//absl/functional:any_invocable
+      # "com_google_absl"
       # Fails with the error: external/org_tensorflow/tensorflow/core/profiler/utils/tf_op_utils.cc:46:49: error: no matching function for call to 're2::RE2::FullMatch(absl::lts_2020_02_25::string_view&, re2::RE2&)'
       # "com_googlesource_code_re2"
       "curl"
@@ -284,7 +288,6 @@ let
       "icu"
       "jsoncpp_git"
       "libjpeg_turbo"
-      "lmdb"
       "nasm"
       "opt_einsum_archive"
       "org_sqlite"

@GaetanLepage
GaetanLepage force-pushed the tensorflow-update branch 2 times, most recently from f34ca9d to 1de8e4f Compare September 10, 2023 11:19
@GaetanLepage

Copy link
Copy Markdown
Contributor Author

I still have the same tf_op_utils.cc error though.

@vcunat
vcunat removed their request for review September 10, 2023 19:44
@GaetanLepage

Copy link
Copy Markdown
Contributor Author

Here is the error I currently face:

ERROR: /build/source/tensorflow/lite/core/tools/BUILD:63:11: Compiling tensorflow/lite/core/tools/verifier_internal.cc failed: (Exit 1): gcc failed: error executing command /nix/st0
In file included from ./tensorflow/lite/core/tools/verifier_internal.h:25,
                 from tensorflow/lite/core/tools/verifier_internal.cc:16:
./tensorflow/lite/schema/schema_generated.h:26:41: error: static assertion failed: Non-compatible flatbuffers version included
   26 |               FLATBUFFERS_VERSION_MINOR == 1 &&
      |                                         ^
./tensorflow/lite/schema/schema_generated.h:26:41: note: the comparison reduces to '(3 == 1)'

@samuela

samuela commented Sep 11, 2023

Copy link
Copy Markdown
Member

Here is the error I currently face:

does removing flatbuffers from the system libs help?

@GaetanLepage

Copy link
Copy Markdown
Contributor Author

does removing flatbuffers from the system libs help?

Ok, I tried removing flatbuffers-core from buildInputs and "flatbuffers" from TF_SYSTEM_LIBS.
No more version issue, but I get the following:

ERROR: /build/output/external/flatbuffers/BUILD.bazel:22:8: declared output 'external/flatbuffers/flatc.bin' was not created by genrule. This is probably because the genrule actually didn't create this output, or because the output was a directory and the genrule was run remotely (note that only the contents of declared file outputs are copied from genrules run remotely)
ERROR: /build/output/external/flatbuffers/BUILD.bazel:22:8: Executing genrule @flatbuffers//:lnflatc [for host] failed: not all outputs were created or valid
which: no flatc in (/build/source/dummy-ldconfig:/nix/store/wq5d9qxwqf2pmrgs0gl4sgh0c4p109hm-which-2.21/bin:/nix/store/sii88jvdjjsp45kd90668vylf12n5qs4-python3-3.10.12-env/bin:/nix/store/xd3ns9wjwchhbpil2ymk9mn9947zmkbl-python3.10-cython-0.29.36/bin:/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/bin:/nix/store/04hllvrsxrw8krjgz0lydxfdy2gg2ndw-perl-5.38.0/bin:/nix/store/z3g9q6vl64a8qkbk277wslqmgbbg0hgw-protobuf-3.24.2/bin:/nix/store/lvxpj767ybdcbz7f5ax5wv8fd3gsy350-bazel-5.4.1/bin:/nix/store/c6aivy3h5kgibrxnciq4l60hraygp07y-patchelf-0.15.0/bin:/nix/store/v1wa8ysdv5lc516fbh25m8ysigwv1k20-gcc-wrapper-12.3.0/bin:/nix/store/4khaz9q96z5nkgvh3150pz2ijhah30pr-gcc-12.3.0/bin:/nix/store/cw6x1hkbjynrlvmb22mh5amwijvxf1i0-glibc-2.37-8-bin/bin:/nix/store/zr0fzzkknaycqj8ij13gk6bhq8lnwxl1-coreutils-9.3/bin:/nix/store/yrjm2yaqy70jacs7mzkvmrg23iyjwm9q-binutils-wrapper-2.40/bin:/nix/store/8zxgqm6d879hskwh5g1l4crysl01kdv0-binutils-2.40/bin:/nix/store/6icx1p3bv29glgx3p3y6i16mcpr1wz0c-jemalloc-5.3.0/bin:/nix/store/280yb8x5l86s40janhsl9313xss7i34j-openmpi-4.1.5/bin:/nix/store/dld0lbflnd2qh92j5nqyfh1z62abnafz-git-2.41.0/bin:/nix/store/3imrq9zi58f31wi6v68fa4x3gjn8qb95-boringssl-2021-07-09-bin/bin:/nix/store/p525sx5yd0fiblmixbhgfkhg4dpwhj5n-curl-8.2.1-dev/bin:/nix/store/mrd7c014k8sji7d5ll0yiaxk529731p8-brotli-1.0.9/bin:/nix/store/8ihllqw53ndm2ylvibyl1h0kbxdabdkw-libkrb5-1.20.1-dev/bin:/nix/store/01qn4g83hjzqmd8yfbb3dz32dzp8zjvg-libkrb5-1.20.1/bin:/nix/store/3iafb6csjbbrynr13jg23l59lxx7p3ks-nghttp2-1.54.0/bin:/nix/store/kfbbcgm5dj38qrzwk6p19hax1f9wxy6v-libidn2-2.3.4-bin/bin:/nix/store/4gpfzxnv0xy9cd5fc8rizb3252gi9zzr-openssl-3.0.10-bin/bin:/nix/store/9yzfj1sj5af85vbgmd33rpwpn0yg0fil-zstd-1.5.5-bin/bin:/nix/store/lg451mdjcnszbbxikdd75v1c4p8gw28y-zstd-1.5.5/bin:/nix/store/l04zxfqxy0sr7rq1rbf1nxcc15via3jn-curl-8.2.1-bin/bin:/nix/store/rk1jaibxvzr9sxvackkw9738yg4v29n3-giflib-5.2.1/bin:/nix/store/9f31wvjqgbsx0k0mih896cirfs4y5pzw-grpc-1.57.0/bin:/nix/store/y2hf4g0gw5hkrmc1bc937jwx2s7affx8-c-ares-1.19.1/bin:/nix/store/vz9q2yngfnzrwzsnsq9m30k1c1nqrwf4-icu4c-73.2-dev/bin:/nix/store/53d1gx3hsf5aabq6spiqdxnq7646kr0y-libjpeg-turbo-2.1.5.1-bin/bin:/nix/store/hzisryd7sp2c4876vbny9lh2plahyzry-libpng-apng-1.6.39-dev/bin:/nix/store/cwm2s7hvnyvhsipqdfvs9z0dkp6v3x6g-python3.10-pybind11-2.11.1/bin:/nix/store/cjvksdvmdwsvy9v105dqg49bs6rm4iiy-sqlite-3.42.0-bin/bin:/nix/store/zr0fzzkknaycqj8ij13gk6bhq8lnwxl1-coreutils-9.3/bin:/nix/store/dybcqb2k9b7qm3f29vm9n3jagxvmmcmr-findutils-4.9.0/bin:/nix/store/wag54ri5wji1gippgrfr7lg3jc8pib97-diffutils-3.10/bin:/nix/store/q8afk7kyb85c0n2h3v0mphnjmdqyj49q-gnused-4.9/bin:/nix/store/d2kvfr3r06rf5zdzsw7ayzj8lkpxh2lx-gnugrep-3.11/bin:/nix/store/3cg1n66ln0l5frnk4lydjajrbf9pavv9-gawk-5.2.2/bin:/nix/store/q5lvjrl7b12vqmsd93h013z9dqkbva0p-gnutar-1.35/bin:/nix/store/mbvy50fhspgwanw0fpns41afchll75br-gzip-1.12/bin:/nix/store/7284vinlwkp93151h6r3jcmdp5463rq9-bzip2-1.0.8-bin/bin:/nix/store/1mas5yrq926sr6n3jvf0zdlrj05rgcbv-gnumake-4.4.1/bin:/nix/store/m36d29gn5gm9bk0g7fcln1v8171hvn95-bash-5.2-p15/bin:/nix/store/wfc1dp9iwi0fw13vv6p06sz987msqgdl-patch-2.7.6/bin:/nix/store/xm6vmd1fq87mh70b793xzs39wnc084sw-xz-5.4.4-bin/bin:/nix/store/qnwqfphvsdgq054dywlvb8n2chxcs38l-file-5.45/bin:/nix/store/dllid2s0v445dfnqfapshm48aarnbcdl-file-5.45/bin:/nix/store/qhyisiwsifbxyqm7j7i3v66yrm952n0q-unzip-6.0/bin:/nix/store/yvvlhg16308kqx0ws2bqwn8wrcgdz86f-zip-3.0/bin)

@natsukium

natsukium commented Sep 15, 2023 •

Copy link
Copy Markdown
Member

I can build tensorflow on x86_64-linux with this patch.

diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix
diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix
index 13f5379ff195..42e20927ad26 100644
--- a/pkgs/development/python-modules/tensorflow/default.nix
+++ b/pkgs/development/python-modules/tensorflow/default.nix
@@ -106,10 +106,10 @@ let
   pythonEnv = python.withPackages (_:
     [ # python deps needed during wheel build time (not runtime, see the buildPythonPackage part for that)
       # This list can likely be shortened, but each trial takes multiple hours so won't bother for now.
-      absl-py
+      # absl-py
       astunparse
       dill
-      flatbuffers-python
+      # flatbuffers-python
       gast
       google-pasta
       grpcio
@@ -215,7 +215,7 @@ let
     # https://gitweb.gentoo.org/repo/gentoo.git/tree/sci-libs/tensorflow
 
     nativeBuildInputs = [
-      which pythonEnv cython perl protobuf-core
+      which pythonEnv cython perl # protobuf-core
     ] ++ lib.optional cudaSupport addOpenGLRunpath;
 
     buildInputs = [
@@ -228,7 +228,7 @@ let
       boringssl
       curl
       double-conversion
-      flatbuffers-core
+      # flatbuffers-core
       giflib
       grpc
       # Necessary to fix the "`GLIBCXX_3.4.30' not found" error
@@ -267,7 +267,7 @@ let
       "boringssl"
       # Not packaged in nixpkgs
       # "com_github_googlecloudplatform_google_cloud_cpp"
-      "com_github_grpc_grpc"
+      # "com_github_grpc_grpc"
       # "com_google_protobuf"
       # ERROR: no such target '@com_google_protobuf//:well_known_types_py_pb2_genproto'
       # https://github.com/tensorflow/tensorflow/issues/60667
@@ -280,7 +280,7 @@ let
       "cython"
       "dill_archive"
       "double_conversion"
-      "flatbuffers"
+      # "flatbuffers"
       "functools32_archive"
       "gast_archive"
       "gif"
@@ -310,7 +310,7 @@ let
     # This is needed for the Nix-provided protobuf dependency to work,
     # as otherwise the rule `link_proto_files` tries to create the links
     # to `/usr/include/...` which results in build failures.
-    PROTOBUF_INCLUDE_PATH = "${protobuf-core}/include";
+    # PROTOBUF_INCLUDE_PATH = "${protobuf-core}/include";
 
     PYTHON_BIN_PATH = pythonEnv.interpreter;
 
@@ -399,7 +399,7 @@ let
       sha256 = {
       x86_64-linux = if cudaSupport
         then ""
-        else "sha256-4SAJ59bJQEjgKdDKlhOclxRIQbW2ITTPYNBbrzbDosk=";
+        else "sha256-aTqHZRNlNQv4THPO81aerHvTjYqTDT87aj2WLIyMQVw=";
       aarch64-linux = "";
       x86_64-darwin = "";
       aarch64-darwin = "";

However, we need more investigation to enable cudaSupport.
This issue might be helpful.
tensorflow/tensorflow#60398

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/rebuild-errors-with-attrsets-and-tensorflow/32927/3

@zeuner

zeuner commented Sep 17, 2023

Copy link
Copy Markdown
Contributor

FYI, if disabling system packages is an option, this is how I got TF 2.13.0 to compile: bcc36f9

Maybe it helps with existing build issues.

Didn't create a PR so far since I'm working on re-enabling system packages for the build.

@GaetanLepage

Copy link
Copy Markdown
Contributor Author

Thanks @zeuner for your input !
I have submitted a PR to update flatbuffers. Maybe it will fix the compilation of TF when using the system flatbuffer.
#255836

@natsukium

Copy link
Copy Markdown
Member

on aarch64-darwin

tensorflow> [16,170 / 17,407] Compiling tensorflow/core/kernels/cwise_op_div.cc; 1339s processwrapper-sandbox ... (8 actions, 7 running)
tensorflow> ERROR: /private/tmp/nix-build-tensorflow-2.13.0.drv-0/source/tensorflow/BUILD:1134:21: declared output 'tensorflow/libtensorflow_framework.2.dylib' is a dangling symbolic link
tensorflow> ERROR: /private/tmp/nix-build-tensorflow-2.13.0.drv-0/source/tensorflow/BUILD:1134:21: Executing genrule //tensorflow:libtensorflow_framework.2.dylib_sym failed: not all outputs were created or valid

I think this issue is related, but I'm not sure how to fix it.
tensorflow/tensorflow#61398

@zeuner

zeuner commented Sep 19, 2023

Copy link
Copy Markdown
Contributor

Thanks @zeuner for your input ! I have submitted a PR to update flatbuffers. Maybe it will fix the compilation of TF when using the system flatbuffer. #255836

AFAIK, TF 2.13.0 actually uses an older version of flatbuffers: https://github.com/tensorflow/tensorflow/blob/v2.13.0/third_party/flatbuffers/workspace.bzl#L8 . Maybe it's possible to regenerate the schemas using a different version, though.

BTW, I got it working with system abseil and protobuf by now: #255998

@GaetanLepage

Copy link
Copy Markdown
Contributor Author

Closing: the update effort is being continued in #255998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants