Skip to content

Commit

Permalink
libtensorflow: 2.16.2 -> 2.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Isidor Zeuner committed Dec 15, 2024
1 parent e2e468d commit 01dce96
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,17 @@ diff -Naurd x/third_party/absl/system.absl.crc.BUILD y/third_party/absl/system.a
+ 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 @@
diff -Naurd x/third_party/absl/system.absl.flags.BUILD y/third_party/absl/system.absl.flags.BUILD
--- x/third_party/absl/system.absl.flags.BUILD 2024-12-15 19:38:44.723946610 +0000
+++ y/third_party/absl/system.absl.flags.BUILD 2024-12-15 19:45:17.312776851 +0000
@@ -97,7 +97,6 @@

cc_library(
name = "any_invocable",
-)
-
-cc_library(
- name = "any_invocable",
name = "flag",
- linkopts = ["-labsl_flags"],
deps = [
"//absl/base:base_internal",
"//absl/base:config",
":config",
":flag_internal",
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
Expand Down Expand Up @@ -204,6 +201,17 @@ diff -Naurd x/third_party/absl/system.absl.strings.BUILD y/third_party/absl/syst
name = "strings",
linkopts = ["-labsl_strings"],
deps = [
diff -Naurd x/third_party/absl/system.absl.synchronization.BUILD y/third_party/absl/system.absl.synchronization.BUILD
--- x/third_party/absl/system.absl.synchronization.BUILD 2024-12-15 19:38:44.723946610 +0000
+++ y/third_party/absl/system.absl.synchronization.BUILD 2024-12-15 19:46:27.336925847 +0000
@@ -20,6 +20,7 @@
name = "synchronization",
linkopts = [
"-labsl_synchronization",
+ "-labsl_kernel_timeout_internal",
"-pthread",
],
deps = [
diff -Naurd x/third_party/absl/workspace.bzl y/third_party/absl/workspace.bzl
--- 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ diff -Naurd x/tensorflow/workspace2.bzl y/tensorflow/workspace2.bzl
@@ -862,6 +862,7 @@
tf_http_archive(
name = "riegeli",
sha256 = "870ca080cdfc5eba696a72ccc3a54cbf0f2271befc0d459eafa8f065edfaadb2",
sha256 = "1d216d5c97fa60632143d209a1bb48c2a83788efdb876902e7bbc06396d5ee1f",
+ patch_file = ["//third_party:riegeli-proto.patch"],
strip_prefix = "riegeli-264ef7b4a1314d97265b37544b27cd3923ea72d2",
urls = tf_mirror_urls("https://github.com/google/riegeli/archive/264ef7b4a1314d97265b37544b27cd3923ea72d2.zip"),
strip_prefix = "riegeli-5d75119232cd4f6db8dfa69a1503289f050e9643",
urls = tf_mirror_urls("https://github.com/google/riegeli/archive/5d75119232cd4f6db8dfa69a1503289f050e9643.zip"),
)
88 changes: 61 additions & 27 deletions pkgs/development/python-modules/tensorflow/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
charset-normalizer,
markupsafe,
psutil,
dm-tree,
optree,
# Common deps
git,
pybind11,
Expand All @@ -59,6 +59,8 @@
lndir,
writeShellScriptBin,
writeText,
patchelf,
unzip,
# Common libraries
jemalloc,
mpi,
Expand Down Expand Up @@ -195,7 +197,7 @@ let

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

version = "2.16.2";
version = "2.17.0";
format = "setuptools";
variant = lib.optionalString cudaSupport "-gpu";
pname = "tensorflow${variant}";
Expand Down Expand Up @@ -520,18 +522,18 @@ let
'';
};

dm-tree-bazel = stdenv.mkDerivation {
name = "${dm-tree.pname}-bazel-${dm-tree.version}";
optree-bazel = stdenv.mkDerivation {
name = "${optree.pname}-bazel-${optree.version}";
src = _bazel-build.deps;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir $out
cp pypi_dm_tree/* $out
cp pypi_optree/* $out
mkdir $out/site-packages
${lndir}/bin/lndir \
${dm-tree}/lib/python${python_dotted}/site-packages \
${optree}/lib/python${python_dotted}/site-packages \
$out/site-packages
runHook postInstall
'';
Expand Down Expand Up @@ -664,7 +666,8 @@ 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_optree=${optree-bazel}"
"--override_repository=ml_dtypes=${ml_dtypes-fix}"
"--override_repository=pypi=${pypi-bazel}"
"--override_repository=python=${python-bazel}"
"--override_repository=python_version_repo=${python_version_repo-bazel}"
Expand All @@ -675,7 +678,6 @@ let
++ lib.optionals cudaSupport [
"--override_repository=nccl_archive=${nccl_archive-fix}"
"--override_repository=eigen_archive=${eigen_archive-fix}"
"--override_repository=ml_dtypes=${ml_dtypes-fix}"
];
})
else
Expand All @@ -699,7 +701,7 @@ let
owner = "tensorflow";
repo = "tensorflow";
rev = "refs/tags/v${version}";
hash = "sha256-yBDS9DFkVLIT+bu/vqh/0U60UwoIzqlTKQsflM7GWCA=";
hash = "sha256-dJGmoYdOTumFdS8AWWGYp5HRxk/WMKQNRi2ubyD/TAU=";
};

# On update, it can be useful to steal the changes from gentoo
Expand All @@ -717,6 +719,7 @@ let
protobuf-extra
wrapped_clang
lndir
patchelf
]
++ lib.optional cudaSupport addDriverRunpath
++ lib.optional stdenv.isDarwin xcbuild
Expand Down Expand Up @@ -849,6 +852,16 @@ 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=";
})
# this commit causes a libprotobuf error in:
# src/google/protobuf/descriptor_database.cc:642
# File already exists in database:
# tensorflow/core/tpu/kernels/sparse_core_layout.proto
(fetchpatch {
name = "fix-sparse-core-layout-proto-duplicate-loading.patch";
url = "https://github.com/tensorflow/tensorflow/commit/1d36138fd0204daa48d97d66e415f46ba91f0697.diff";
hash = "sha256-1rzz9zNTQVdKMI3ByeNT/CdLhOiCaYSrDE+/C31ekig=";
revert = true;
})
./fix-syslib-references.patch
./protobuf_lite.patch
./protobuf_cc_toolchain.patch
Expand All @@ -875,6 +888,8 @@ let
rm -f .bazelversion
patchShebangs .
ln -s ${./riegeli-proto.patch} third_party/riegeli-proto.patch
substituteInPlace tensorflow/tools/pip_package/build_pip_package.py \
--replace-fail '"patchelf"' '"${patchelf}/bin/patchelf"'
''
+ lib.optionalString (!stdenv.isDarwin) ''
sed \
Expand Down Expand Up @@ -952,7 +967,7 @@ let
] ++ lib.optionals (mklSupport) [ "--config=mkl" ];

bazelTargets = [
"//tensorflow/tools/pip_package:build_pip_package //tensorflow/tools/lib_package:libtensorflow"
"//tensorflow/tools/pip_package:wheel //tensorflow/tools/lib_package:libtensorflow"
];

removeRulesCC = false;
Expand All @@ -977,7 +992,8 @@ 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
rm -rf external/pypi_optree/site-packages
rm -rf external/pypi_ml_dtypes/site-packages
''
+ lib.optionalString (stdenv.isAarch64) ''
rm -rf external/pypi_psutil/site-packages
Expand Down Expand Up @@ -1015,12 +1031,12 @@ let
if cudaSupport then
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
else
"sha256-SlIIHoD4mLcUbcjkXch/NFA4khbHsj19v05Z6xMX0/Q=";
"sha256-bg3ii3T/Ic01xV73lSA2SYVmDIkNCasQo6fEhk9lVVk=";
aarch64-linux =
if cudaSupport then
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
else
"sha256-bGa4OVl0UtD1qZS/zlcnLnm72UbZEr2n2HtJOUprRTs=";
"sha256-d+wVbOzKGHM/yVlPiL/n8Uc/aqdhthPQhE4YMJlrLp8=";
# deps hashes can't be computed for the Darwin platforms as of
# 2024-10-21 as the expressions don't evaluate due to
# python3Packages.jaraco-path being broken on these platforms
Expand All @@ -1038,7 +1054,7 @@ let

# need to rebuild schemas since we use a different flatbuffers version
preBuild = ''
(cd tensorflow/lite/schema;${flatbuffers-core}/bin/flatc --gen-object-api -c schema.fbs)
(cd tensorflow/lite/schema;${flatbuffers-core}/bin/flatc --gen-object-api -c schema_v3c.fbs)
(cd tensorflow/lite/schema;${flatbuffers-core}/bin/flatc --gen-object-api -c conversion_metadata.fbs)
(cd tensorflow/lite/acceleration/configuration;${flatbuffers-core}/bin/flatc -o configuration.fbs --proto configuration.proto)
sed -i s,tflite.proto,tflite,g tensorflow/lite/acceleration/configuration/configuration.fbs/configuration.fbs
Expand Down Expand Up @@ -1066,10 +1082,9 @@ let
Cflags: -I$out/include/tensorflow
EOF
# build the source code, then copy it to $python (build_pip_package
# actually builds a symlink farm so we must dereference them).
bazel-bin/tensorflow/tools/pip_package/build_pip_package --src "$PWD/dist"
cp -Lr "$PWD/dist" "$python"
mkdir "$python"
cp bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-${version}-*.whl \
"$python/${pname}-${version}.whl"
'';

postFixup = lib.optionalString cudaSupport ''
Expand Down Expand Up @@ -1108,7 +1123,29 @@ buildPythonPackage {
inherit version pname;
disabled = pythonOlder "3.9";

src = bazel-build.python;
format = "other";

src = "${bazel-build.python}/${pname}-${version}.whl";

sourceRoot = ".";

unpackPhase = ''
runHook preUnpack
${unzip}/bin/unzip $src
runHook postUnpack
'';

dontConfigure = true;
dontBuild = true;

installPhase = ''
runHook preInstall
mkdir -p $out/${python.sitePackages}
cp -r $sourceRoot/tensorflow* $out/${python.sitePackages}
runHook postInstall
'';

# Adjust dependency requirements:
# - Drop tensorflow-io dependency until we get it to build
Expand All @@ -1127,14 +1164,6 @@ buildPythonPackage {
"keras"
];

# Upstream has a pip hack that results in bin/tensorboard being in both tensorflow
# and the propagated input tensorboard, which causes environment collisions.
# Another possibility would be to have tensorboard only in the buildInputs
# https://github.com/tensorflow/tensorflow/blob/v1.7.1/tensorflow/tools/pip_package/setup.py#L79
postInstall = ''
rm $out/bin/tensorboard
'';

setupPyGlobalFlags = [ "--project_name ${pname}" ];

# tensorflow/tools/pip_package/setup.py
Expand Down Expand Up @@ -1189,8 +1218,13 @@ buildPythonPackage {
# TODO better test (files in tensorflow/tools/ci_build/builds/*test)
# TEST_PACKAGES in tensorflow/tools/pip_package/setup.py
nativeCheckInputs = [
curl
dill
double-conversion
grpc
jsoncpp
portpicker
snappy
tblib
];
checkPhase = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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
@@ -209,7 +209,7 @@
@@ -89,13 +89,12 @@
"@com_google_protobuf//:LICENSE",
"@curl//:COPYING",
"@ducc//:LICENSE",
Expand All @@ -10,3 +10,9 @@ diff -Naurd x/tensorflow/tools/pip_package/BUILD y/tensorflow/tools/pip_package/
"@gemmlowp//:LICENSE",
"@libjpeg_turbo//:LICENSE.md",
"@llvm-project//llvm:LICENSE.TXT",
"@llvm-project//mlir:LICENSE.TXT",
"@local_config_tensorrt//:LICENSE",
- "@ml_dtypes//:LICENSE",
"@org_brotli//:LICENSE",
"@pasta//:LICENSE",
"@png//:LICENSE",
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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 @@
@@ -4,7 +4,11 @@
"proto_gen",
"py_proto_library",
)
-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 @@

licenses(["notice"])

@@ -124,3 +128,13 @@
srcs = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()],
visibility = ["//visibility:public"],
)
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15326,7 +15326,7 @@ self: super: with self; {

tensorflow-build = let
compat = rec {
abseil-cppTF = pkgs.abseil-cpp_202301;
abseil-cppTF = pkgs.abseil-cpp_202401;
# https://www.tensorflow.org/install/source#gpu
cudaPackagesTF = pkgs.cudaPackages_11;
};
Expand Down

0 comments on commit 01dce96

Please sign in to comment.