Skip to content

Commit

Permalink
libtensorflow: 2.14.0 -> 2.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Isidor Zeuner committed Oct 12, 2024
1 parent c428490 commit 660de55
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 176 deletions.
14 changes: 0 additions & 14 deletions pkgs/development/python-modules/tensorflow/compute-links.patch

This file was deleted.

12 changes: 0 additions & 12 deletions pkgs/development/python-modules/tensorflow/compute-relative.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff -Naurd x/tensorflow/workspace2.bzl y/tensorflow/workspace2.bzl
--- x/tensorflow/workspace2.bzl 2023-12-07 09:42:06.557980143 +0000
+++ y/tensorflow/workspace2.bzl 2023-12-07 09:43:50.613924139 +0000
@@ -862,6 +862,7 @@
tf_http_archive(
name = "riegeli",
sha256 = "870ca080cdfc5eba696a72ccc3a54cbf0f2271befc0d459eafa8f065edfaadb2",
+ patch_file = ["//third_party:riegeli-proto.patch"],
strip_prefix = "riegeli-264ef7b4a1314d97265b37544b27cd3923ea72d2",
urls = tf_mirror_urls("https://github.com/google/riegeli/archive/264ef7b4a1314d97265b37544b27cd3923ea72d2.zip"),
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
diff -Naurd x/WORKSPACE y/WORKSPACE
--- x/WORKSPACE 2023-11-16 08:55:37.370373002 +0000
+++ y/WORKSPACE 2023-11-20 01:55:57.812931627 +0000
@@ -17,6 +17,10 @@
sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
strip_prefix = "rules_python-0.23.1",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz",
@@ -17,6 +17,9 @@
sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
strip_prefix = "rules_python-0.26.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
+ patches = [
+ "//tensorflow:rules-python-use-nix.patch",
+ "//tensorflow:rules-python-newer-versions.patch",
+ "//tensorflow:rules-python-use-nix.patch"
+ ],
)

Expand Down
93 changes: 42 additions & 51 deletions pkgs/development/python-modules/tensorflow/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ let

tfFeature = x: if x then "1" else "0";

version = "2.14.0";
version = "2.15.0";
format = "setuptools";
variant = lib.optionalString cudaSupport "-gpu";
pname = "tensorflow${variant}";
Expand Down Expand Up @@ -411,6 +411,22 @@ let
'';
};

wrapt-bazel = stdenv.mkDerivation {
name = "${wrapt.pname}-bazel-${wrapt.version}";
src = _bazel-build.deps;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir $out
cp pypi_wrapt/* $out
mkdir $out/site-packages
${lndir}/bin/lndir ${wrapt}/lib/python${python_dotted}/site-packages \
$out/site-packages
runHook postInstall
'';
};

markupsafe-bazel = stdenv.mkDerivation {
name = "${markupsafe.pname}-bazel-${markupsafe.version}";
src = _bazel-build.deps;
Expand Down Expand Up @@ -499,6 +515,7 @@ let
"--override_repository=pypi_numpy=${numpy-bazel}"
"--override_repository=pypi_grpcio=${grpcio-bazel}"
"--override_repository=pypi_h5py=${h5py-bazel}"
"--override_repository=pypi_wrapt=${wrapt-bazel}"
"--override_repository=pypi_markupsafe=${markupsafe-bazel}"
"--override_repository=pypi=${pypi-bazel}"
"--override_repository=python=${python-bazel}"
Expand All @@ -516,7 +533,7 @@ let
owner = "tensorflow";
repo = "tensorflow";
rev = "refs/tags/v${version}";
hash = "sha256-OvYb1YkYT9xeUGz3yBRdgNd/0s4YNhXPlw7yOR7pxB0=";
hash = "sha256-tCFLEvJ1lHy7NcHDW9Dkd+2D60x+AvOB8EAwmUSQCtM=";
};

# On update, it can be useful to steal the changes from gentoo
Expand Down Expand Up @@ -611,7 +628,6 @@ let
"jsoncpp_git"
"libjpeg_turbo"
"nasm"
"opt_einsum_archive"
"org_sqlite"
"pasta"
"png"
Expand Down Expand Up @@ -667,27 +683,22 @@ 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 {
name = "fix-clang16-build.patch";
url = "https://github.com/tensorflow/tensorflow/commit/055b7147a436360110480ba1ef97f4216e1909d8.diff";
hash = "sha256-3eLmKMjcbYrb/RnpEuCYj4iOK4iMs3IVy976ruKPmTk=";
})
(fetchpatch {
url = "https://github.com/openxla/xla/commit/30c1666bf76616b6d6569a262a6cc705b3ce5f47.diff";
name = "denormal-cstdint.patch";
stripLen = 3;
extraPrefix = "tensorflow/";
decode = "sed 's<\"tsl/<\"tensorflow/tsl/<'";
hash = "sha256-Dm3NoEvChdNolunLIDlyD1anwtUlbnfBT4GBj2w0caM=";
stripLen = 1;
extraPrefix = "third_party/xla/";
hash = "sha256-kOXFVFM3Z1945gLoJhTiCvriiWTzlGcm92URWasO5hM=";
})
./fix-syslib-references.patch
./protobuf_lite.patch
./protobuf_cc_toolchain.patch
./pybind11-osx.patch
./com_google_absl_add_log.patch
./core-riegeli-proto.patch
./protobuf_python.patch
./pybind11_protobuf_python_runtime_dep.patch
./pybind11_protobuf_newer_version.patch
# the implementation from upstream using realpath breaks in the sandbox
./compute-links.patch
./add-python-312.patch
]
++ lib.optionals (!stdenv.isDarwin) [
Expand All @@ -701,32 +712,11 @@ let
# bazel 3.3 should work just as well as bazel 3.1
rm -f .bazelversion
patchShebangs .
sed 's,@bash@,${stdenv.shell},g' < ${./compute-relative.sh} \
> tensorflow/compute-relative.sh
chmod +x tensorflow/compute-relative.sh
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 \
"00258cbe3f5188629828363ae8ff78477ce976a6f63fb2bb5e90088396faa82e" \
"5711c51e204dc52065f4a3327dca46e69636a0b76d3e98c2c28c4ccef9b04c52" \
--replace-fail \
"092fa155b945015754bdf988be47793c377b52b88d546e45c6a9f9579ac7f7b6" \
"956f0b7cb465a65de1bd90d5a7475b4dc55089b25042fe0f6c870707e9aabb1d" \
''
+ lib.optionalString (!stdenv.isx86_64) ''
--replace-fail \
"0f80bf37f09e1caba6a8063e56e2b87fa335add314cf2b78ebf7cb45aa7e3d06" \
"2f120d27051e4c59db2f267b71b833796770d3ea36ca712befa8c5fff5da6ebd" \
--replace-fail \
"20ec6fc4ad47d1b6e12deec5045ec3cd5402d9a1597f738263e98f490fe07056" \
"0b84445fa94d59e6806c10266b977f92fa997db3585f125d6b751af02ff8b9fe" \
''
+ ''
--replace-fail "grpcio==1.57.0" "grpcio==1.59.0" \
''
+ lib.optionalString (stdenv.isx86_64) ''
--replace-fail \
"0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d" \
Expand All @@ -741,14 +731,13 @@ let
"9fad7dcb1aac3c7f0584a5a8133e3a43eeb2fe127f47e3632d43d677c66c102b" \
''
+ ''
--replace-fail "numpy==1.23.5" "numpy==1.26.4"
cp ${./rules-python-newer-versions.patch} \
tensorflow/rules-python-newer-versions.patch
--replace-fail "numpy==1.23.5" "numpy==1.26.4"
''
+ lib.optionalString (!stdenv.isDarwin) ''
sed \
-e 's,@python@,${pythonEnv},g' \
-e 's,@python_version@,${python.version},g' \
-e 's,@version_long@,${python_dotted},g' \
< ${./rules-python-use-nix.patch} \
> tensorflow/rules-python-use-nix.patch
''
Expand All @@ -762,9 +751,6 @@ let
sed -i '/tensorboard ~=/d' tensorflow/tools/pip_package/setup.py
'';

# https://github.com/tensorflow/tensorflow/pull/39470
env.NIX_CFLAGS_COMPILE = toString [ "-Wno-stringop-truncation" ];

preConfigure =
let
opt_flags =
Expand Down Expand Up @@ -830,6 +816,7 @@ let
rm -f external/pypi_numpy/rules_python_wheel_entry_point_f2py${python_dotted}.py
rm -rf external/pypi_grpcio/site-packages
rm -rf external/pypi_h5py/site-packages
rm -rf external/pypi_wrapt/site-packages
rm -rf external/pypi_markupsafe/site-packages
substituteInPlace external/pypi/requirements.bzl \
--replace-fail ${python_underscored} @version_underscored@
Expand All @@ -843,7 +830,10 @@ let
rm -rf external/python_*-unknown-linux-gnu/share
substituteInPlace external/python_*-unknown-linux-gnu/BUILD.bazel \
--replace-fail python${python_dotted} python@version_long@ \
--replace-fail python${python_undotted} python@version_short@
--replace-fail python${python_undotted} python@version_short@ \
--replace-fail \
'python_version = "${python_dotted}"' \
'python_version = "@version_long@"'
substituteInPlace external/rules_python/python/repositories.bzl \
--replace-fail ${pythonEnv} @python@ \
--replace-fail ${python.version} @python_version@
Expand All @@ -856,12 +846,12 @@ let
if cudaSupport then
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
else
"sha256-D/HhjfKhaJ6ypizxHuFvwMyavxf4t+9+q3PBWIaPn+0=";
"sha256-ZJcKpHUWymY86Zhndg/X76xLN8qNRMJpMG9Vbmzpqx4=";
aarch64-linux =
if cudaSupport then
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
else
"sha256-v1vfVFeDzFuCRI1OL7rV4E6KVLlceJ+f0n8WLPbpxxg=";
"sha256-RCdtej+7d8mJHVLgBzBs3XGQslgG3fbBTQI++qDBDBQ=";
x86_64-darwin = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
aarch64-darwin = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
}
Expand Down Expand Up @@ -948,10 +938,6 @@ buildPythonPackage {

src = bazel-build.python;

patches = [
./remove-keras-dependency.patch
];

# Adjust dependency requirements:
# - Drop tensorflow-io dependency until we get it to build
# - Relax flatbuffers and gast version requirements
Expand Down Expand Up @@ -1003,7 +989,13 @@ buildPythonPackage {
wrapt
] ++ lib.optionals withTensorboard [ tensorboard ];

nativeBuildInputs = lib.optionals cudaSupport [ addDriverRunpath ];
nativeBuildInputs =
[
pythonRelaxDepsHook
]
++ lib.optionals cudaSupport [
addDriverRunpath
];

postFixup = lib.optionalString cudaSupport (
''
Expand Down Expand Up @@ -1052,7 +1044,6 @@ buildPythonPackage {
passthru = {
deps = bazel-build.deps;
libtensorflow = bazel-build.out;
ml-dtypesTF = ml-dtypes;
};

inherit (bazel-build) meta;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff -Naurd x/tensorflow/tools/pip_package/BUILD y/tensorflow/tools/pip_package/BUILD
--- x/tensorflow/tools/pip_package/BUILD 2023-10-14 20:09:43.001857258 +0000
+++ y/tensorflow/tools/pip_package/BUILD 2023-10-14 20:15:17.894102008 +0000
@@ -208,7 +208,7 @@
@@ -209,7 +209,7 @@
"@com_google_protobuf//:LICENSE",
"@curl//:COPYING",
"@dill_archive//:LICENSE",
"@ducc//:LICENSE",
- "@flatbuffers//:LICENSE",
+ "@flatbuffers//:LICENSE.txt",
"@gast_archive//:PKG-INFO",
"@gemmlowp//:LICENSE",
"@libjpeg_turbo//:LICENSE.md",
"@llvm-project//llvm:LICENSE.TXT",
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff -Naurd x/third_party/systemlibs/protobuf.BUILD y/third_party/systemlibs/protobuf.BUILD
--- x/third_party/systemlibs/protobuf.BUILD 2023-12-03 15:39:27.742087246 +0000
+++ y/third_party/systemlibs/protobuf.BUILD 2023-12-04 13:25:41.777638732 +0000
@@ -1,4 +1,8 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
+load(
+ "@rules_proto//proto:defs.bzl",
+ "proto_lang_toolchain",
+ "proto_library",
+)
load(
"@com_google_protobuf//:protobuf.bzl",
"cc_proto_library",
@@ -118,3 +122,13 @@
srcs = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()],
visibility = ["//visibility:public"],
)
+
+proto_lang_toolchain(
+ name = "cc_toolchain",
+ blacklisted_protos = [
+ "//:compiler_plugin_proto",
+ "//:descriptor_proto",
+ ],
+ command_line = "--cpp_out=$(OUT)",
+ visibility = ["//visibility:public"],
+)
16 changes: 16 additions & 0 deletions pkgs/development/python-modules/tensorflow/protobuf_lite.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff -Naurd x/third_party/systemlibs/protobuf.BUILD y/third_party/systemlibs/protobuf.BUILD
--- x/third_party/systemlibs/protobuf.BUILD 2023-12-03 15:39:27.742087246 +0000
+++ y/third_party/systemlibs/protobuf.BUILD 2023-12-03 20:23:49.345014695 +0000
@@ -66,6 +66,12 @@
)

cc_library(
+ name = "protobuf_lite",
+ linkopts = ["-lprotobuf-lite"],
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
name = "protobuf_headers",
linkopts = ["-lprotobuf"],
visibility = ["//visibility:public"],
36 changes: 36 additions & 0 deletions pkgs/development/python-modules/tensorflow/riegeli-proto.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff -Naurd x/riegeli/records/BUILD y/riegeli/records/BUILD
--- x/riegeli/records/BUILD 2023-12-06 16:24:03.939575600 +0000
+++ y/riegeli/records/BUILD 2023-12-06 16:23:00.079531687 +0000
@@ -1,4 +1,4 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
+load("@local_tsl//tsl/platform:build_config.bzl", "tf_proto_library")

package(
default_visibility = ["//visibility:public"],
@@ -14,7 +14,7 @@
deps = [
":chunk_reader",
":record_position",
- ":records_metadata_cc_proto",
+ ":records_metadata_proto_cc_impl",
":skipped_region",
"//riegeli/base:arithmetic",
"//riegeli/base:assert",
@@ -184,13 +184,10 @@
],
)

-proto_library(
+tf_proto_library(
name = "records_metadata_proto",
srcs = ["records_metadata.proto"],
- deps = ["@com_google_protobuf//:descriptor_proto"],
-)
-
-cc_proto_library(
- name = "records_metadata_cc_proto",
- deps = [":records_metadata_proto"],
+ cc_api_version = 2,
+ make_default_target_header_only = True,
+ visibility = ["//visibility:public"],
)
Loading

0 comments on commit 660de55

Please sign in to comment.