From c1b00c89e84f939a4e2008c14e954a9615213d5c Mon Sep 17 00:00:00 2001 From: Isidor Zeuner Date: Sun, 13 Oct 2024 22:47:23 +0200 Subject: [PATCH] libtensorflow: 2.15.0 -> 2.16.2 --- .../tensorflow/add-python-312.patch | 12 ---- .../tensorflow/com_google_absl_add_log.patch | 64 +++++++++++++++++-- .../python-modules/tensorflow/default.nix | 63 ++++++++---------- 3 files changed, 86 insertions(+), 53 deletions(-) delete mode 100644 pkgs/development/python-modules/tensorflow/add-python-312.patch diff --git a/pkgs/development/python-modules/tensorflow/add-python-312.patch b/pkgs/development/python-modules/tensorflow/add-python-312.patch deleted file mode 100644 index 7b983f99f38755..00000000000000 --- a/pkgs/development/python-modules/tensorflow/add-python-312.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Naurd x/tensorflow/tools/toolchains/python/python_repo.bzl y/tensorflow/tools/toolchains/python/python_repo.bzl ---- x/tensorflow/tools/toolchains/python/python_repo.bzl 2024-10-08 07:49:21.408314991 +0000 -+++ y/tensorflow/tools/toolchains/python/python_repo.bzl 2024-10-08 07:52:22.552639011 +0000 -@@ -4,7 +4,7 @@ - Defaults to 3.10. - """ - --VERSIONS = ["3.9", "3.10", "3.11"] -+VERSIONS = ["3.9", "3.10", "3.11", "3.12"] - DEFAULT_VERSION = "3.10" - WARNING = """ - TF_PYTHON_VERSION variable was not set correctly, using default version. {} Python diff --git a/pkgs/development/python-modules/tensorflow/com_google_absl_add_log.patch b/pkgs/development/python-modules/tensorflow/com_google_absl_add_log.patch index 06b83bf53f025b..b9f0901c9b6c84 100644 --- a/pkgs/development/python-modules/tensorflow/com_google_absl_add_log.patch +++ b/pkgs/development/python-modules/tensorflow/com_google_absl_add_log.patch @@ -1,7 +1,16 @@ diff -Naurd x/third_party/absl/system.absl.base.BUILD y/third_party/absl/system.absl.base.BUILD --- x/third_party/absl/system.absl.base.BUILD 2023-09-17 09:12:05.499753364 +0000 +++ y/third_party/absl/system.absl.base.BUILD 2023-09-17 09:16:01.200082822 +0000 -@@ -22,7 +22,13 @@ +@@ -12,6 +12,8 @@ + "atomic_hook", + "errno_saver", + "fast_type_id", ++ "nullability", ++ "prefetch", + "pretty_function", + ]] + +@@ -22,7 +24,13 @@ cc_library( name = "raw_logging_internal", @@ -16,10 +25,35 @@ diff -Naurd x/third_party/absl/system.absl.base.BUILD y/third_party/absl/system. visibility = [ "//absl:__subpackages__", ], +diff -Naurd x/third_party/absl/system.absl.crc.BUILD y/third_party/absl/system.absl.crc.BUILD +--- x/third_party/absl/system.absl.crc.BUILD 1970-01-01 00:00:00.000000000 +0000 ++++ y/third_party/absl/system.absl.crc.BUILD 2024-10-10 20:08:56.809477492 +0000 +@@ -0,0 +1,7 @@ ++load("@rules_cc//cc:defs.bzl", "cc_library") ++ ++cc_library( ++ name = "crc32c", ++ linkopts = ["-labsl_crc32c"], ++ visibility = ["//visibility:public"], ++) +diff -Naurd x/third_party/absl/system.absl.functional.BUILD y/third_party/absl/system.absl.functional.BUILD +--- x/third_party/absl/system.absl.functional.BUILD 2024-10-10 10:15:40.640185040 +0000 ++++ y/third_party/absl/system.absl.functional.BUILD 2024-10-10 10:17:59.221375986 +0000 +@@ -4,10 +4,6 @@ + + cc_library( + name = "any_invocable", +-) +- +-cc_library( +- name = "any_invocable", + deps = [ + "//absl/base:base_internal", + "//absl/base:config", diff -Naurd x/third_party/absl/system.absl.log.BUILD y/third_party/absl/system.absl.log.BUILD --- x/third_party/absl/system.absl.log.BUILD 1970-01-01 00:00:00.000000000 +0000 +++ y/third_party/absl/system.absl.log.BUILD 2023-09-17 09:12:11.795762177 +0000 -@@ -0,0 +1,134 @@ +@@ -0,0 +1,135 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +package(default_visibility = ["//visibility:public"]) @@ -44,6 +78,7 @@ diff -Naurd x/third_party/absl/system.absl.log.BUILD y/third_party/absl/system.a + +cc_library( + name = "die_if_null", ++ linkopts = ["-labsl_die_if_null"], + deps = [ + ":log", + "//absl/base:config", @@ -154,10 +189,29 @@ diff -Naurd x/third_party/absl/system.absl.log.BUILD y/third_party/absl/system.a + "//absl/strings", + ], +) +diff -Naurd x/third_party/absl/system.absl.strings.BUILD y/third_party/absl/system.absl.strings.BUILD +--- x/third_party/absl/system.absl.strings.BUILD 2024-10-10 10:15:40.644185074 +0000 ++++ y/third_party/absl/system.absl.strings.BUILD 2024-10-10 18:52:37.648334488 +0000 +@@ -3,6 +3,10 @@ + package(default_visibility = ["//visibility:public"]) + + cc_library( ++ name = "string_view", ++) ++ ++cc_library( + name = "strings", + linkopts = ["-labsl_strings"], + deps = [ diff -Naurd x/third_party/absl/workspace.bzl y/third_party/absl/workspace.bzl ---- x/third_party/absl/workspace.bzl 2023-09-17 09:12:05.499753364 +0000 -+++ y/third_party/absl/workspace.bzl 2023-09-17 09:12:11.795762177 +0000 -@@ -20,6 +20,7 @@ +--- x/third_party/absl/workspace.bzl 2024-10-10 10:16:56.508840929 +0000 ++++ y/third_party/absl/workspace.bzl 2024-10-10 20:09:16.685514935 +0000 +@@ -16,10 +16,12 @@ + "base", + "cleanup", + "container", ++ "crc", + "debugging", "flags", "functional", "hash", diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix index 4e8d50f24488d1..b2ab3fceee3670 100644 --- a/pkgs/development/python-modules/tensorflow/default.nix +++ b/pkgs/development/python-modules/tensorflow/default.nix @@ -43,6 +43,7 @@ distutils, charset-normalizer, markupsafe, + dm-tree, # Common deps git, pybind11, @@ -53,7 +54,7 @@ perl, clang, pkg-config, - ninja, + cmake, lndir, # Common libraries jemalloc, @@ -192,7 +193,7 @@ let tfFeature = x: if x then "1" else "0"; - version = "2.15.0"; + version = "2.16.2"; format = "setuptools"; variant = lib.optionalString cudaSupport "-gpu"; pname = "tensorflow${variant}"; @@ -444,6 +445,23 @@ let ''; }; + dm-tree-bazel = stdenv.mkDerivation { + name = "${dm-tree.pname}-bazel-${dm-tree.version}"; + src = _bazel-build.deps; + dontConfigure = true; + dontBuild = true; + installPhase = '' + runHook preInstall + mkdir $out + cp pypi_dm_tree/* $out + mkdir $out/site-packages + ${lndir}/bin/lndir \ + ${dm-tree}/lib/python${python_dotted}/site-packages \ + $out/site-packages + runHook postInstall + ''; + }; + pypi-bazel = stdenv.mkDerivation { name = "pypi-bazel"; src = _bazel-build.deps; @@ -517,6 +535,7 @@ let "--override_repository=pypi_h5py=${h5py-bazel}" "--override_repository=pypi_wrapt=${wrapt-bazel}" "--override_repository=pypi_markupsafe=${markupsafe-bazel}" + "--override_repository=pypi_dm_tree=${dm-tree-bazel}" "--override_repository=pypi=${pypi-bazel}" "--override_repository=python=${python-bazel}" "--override_repository=python_version_repo=${python_version_repo-bazel}" @@ -533,7 +552,7 @@ let owner = "tensorflow"; repo = "tensorflow"; rev = "refs/tags/v${version}"; - hash = "sha256-tCFLEvJ1lHy7NcHDW9Dkd+2D60x+AvOB8EAwmUSQCtM="; + hash = "sha256-yBDS9DFkVLIT+bu/vqh/0U60UwoIzqlTKQsflM7GWCA="; }; # On update, it can be useful to steal the changes from gentoo @@ -554,7 +573,7 @@ let ] ++ lib.optional cudaSupport addDriverRunpath ++ lib.optional stdenv.isDarwin xcbuild - ++ lib.optional (pythonAtLeast "3.12") ninja; + ++ lib.optional stdenv.isAarch64 cmake; buildInputs = [ @@ -683,13 +702,6 @@ let url = "https://raw.githubusercontent.com/conda-forge/tensorflow-feedstock/0a63c5a962451b4da99a9948323d8b3ed462f461/recipe/patches/0001-Omit-linking-to-layout_proto_cc-if-protobuf-linkage-.patch"; hash = "sha256-/7buV6DinKnrgfqbe7KKSh9rCebeQdXv2Uj+Xg/083w="; }) - (fetchpatch { - url = "https://github.com/openxla/xla/commit/30c1666bf76616b6d6569a262a6cc705b3ce5f47.diff"; - name = "denormal-cstdint.patch"; - stripLen = 1; - extraPrefix = "third_party/xla/"; - hash = "sha256-kOXFVFM3Z1945gLoJhTiCvriiWTzlGcm92URWasO5hM="; - }) ./fix-syslib-references.patch ./protobuf_lite.patch ./protobuf_cc_toolchain.patch @@ -699,7 +711,6 @@ let ./protobuf_python.patch ./pybind11_protobuf_python_runtime_dep.patch ./pybind11_protobuf_newer_version.patch - ./add-python-312.patch ] ++ lib.optionals (!stdenv.isDarwin) [ # we override Python in the bazel build anyway, but we also need @@ -713,28 +724,6 @@ let rm -f .bazelversion patchShebangs . ln -s ${./riegeli-proto.patch} third_party/riegeli-proto.patch - ! test -e requirements_lock_3_12.txt - cp requirements_lock_3_11.txt requirements_lock_3_12.txt - substituteInPlace requirements_lock_*.txt \ - '' - + lib.optionalString (stdenv.isx86_64) '' - --replace-fail \ - "0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d" \ - "666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5" \ - --replace-fail \ - "1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a" \ - "675d61ffbfa78604709862923189bad94014bef562cc35cf61d3a07bba02a7ed" \ - --replace-fail \ - "09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df" \ - "ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f" \ - '' - + lib.optionalString (!stdenv.isx86_64) '' - --replace-fail \ - "01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d" \ - "9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b" \ - '' - + '' - --replace-fail "numpy==1.23.5" "numpy==1.26.4" '' + lib.optionalString (!stdenv.isDarwin) '' sed \ @@ -821,12 +810,14 @@ let rm -rf external/pypi_h5py/site-packages rm -rf external/pypi_wrapt/site-packages rm -rf external/pypi_markupsafe/site-packages + rm -rf external/pypi_dm_tree/site-packages substituteInPlace external/pypi/requirements.bzl \ --replace-fail ${python_underscored} @version_underscored@ substituteInPlace external/python_version_repo/py_version.bzl \ --replace-fail ${python_dotted} @version_long@ sed -i 's/(\("[^(),]*"\), "\([^()]*\)==[^()]*")/(\1, "\2")/g' \ external/pypi/requirements.bzl + sed -i 's/, "pypi_version=[0-9.]*"//' external/pypi_numpy/BUILD.bazel rm -rf external/python_*-unknown-linux-gnu/bin rm -rf external/python_*-unknown-linux-gnu/include rm -rf external/python_*-unknown-linux-gnu/lib @@ -851,12 +842,12 @@ let if cudaSupport then "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" else - "sha256-gedyY/NKyxYyuN1p2IstsnONwI0bbYcVyBi4Ivzkrck="; + "sha256-SlIIHoD4mLcUbcjkXch/NFA4khbHsj19v05Z6xMX0/Q="; aarch64-linux = if cudaSupport then "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" else - "sha256-rhpCziyFhhUhe2eKUAwotOGq0Qnyf4RXrK5SiN4sz1w="; + "sha256-tFy0sihrcchnXGO5UqR4npb8MoHSeQCxD/IB1b+/Gks="; x86_64-darwin = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; aarch64-darwin = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; }