Skip to content

Commit

Permalink
updpkg: 2.17.0-1
Browse files Browse the repository at this point in the history
  • Loading branch information
acxz committed Jul 21, 2024
1 parent cf344c9 commit fa64355
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 61 deletions.
19 changes: 10 additions & 9 deletions .SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = tensorflow-rocm
pkgdesc = Library for computation using data flow graphs for scalable machine learning
pkgver = 2.15.0
pkgrel = 8
pkgver = 2.17.0
pkgrel = 1
url = https://www.tensorflow.org/
arch = x86_64
license = APACHE
Expand All @@ -24,7 +24,6 @@ pkgbase = tensorflow-rocm
makedepends = python-requests
makedepends = libxcrypt-compat
makedepends = clang
makedepends = jdk11-openjdk
depends = c-ares
depends = pybind11
depends = openssl
Expand All @@ -36,12 +35,14 @@ pkgbase = tensorflow-rocm
depends = intel-oneapi-openmp
depends = intel-oneapi-compiler-shared-runtime-libs
optdepends = tensorboard: Tensorflow visualization toolkit
source = tensorflow-rocm-2.15.0.tar.gz::https://github.com/tensorflow/tensorflow/archive/v2.15.0.tar.gz
source = https://github.com/bazelbuild/bazel/releases/download/6.1.0/bazel_nojdk-6.1.0-linux-x86_64
source = fix-c++17-compat.patch
sha512sums = 51976c7255ffbdb98fe67a28f6ae1c3b9a073e49fe6b44187a53d99654e4af753de53bfa7229cdd1997ac71e8ddecbc15e4759d46c6d24b55eb84c5d31523dfe
sha512sums = b71aed83ae1c3f610df77f7c148703fd3e7aa5901794a2b31c6044c71b3f030831d59f7f3641992105117a422655160fc9b509326b31586c6bca378cbff08762
sha512sums = f682368bb47b2b022a51aa77345dfa30f3b0d7911c56515d428b8326ee3751242f375f4e715a37bb723ef20a86916dad9871c3c81b1b58da85e1ca202bc4901e
source = tensorflow-rocm-2.17.0.tar.gz::https://github.com/tensorflow/tensorflow/archive/v2.17.0.tar.gz
source = tensorflow-2.16.1-python-distutils-removal.patch
source = tensorflow-numpy2.patch
source = https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel_nojdk-6.5.0-linux-x86_64
sha512sums = 45061f075971cf2bc219a34b1cda2ee9851ba586e94046838e6e1fd26adcfb399d90e71e89a0f709d5282ff3be7cc3a82b81d62dce53db5010640ea41487a469
sha512sums = e4c44d2f5314b83d8ed404e5ec14960ef8b7df0c1a2a3e826f913a02c901f9fd0326f9014a602121e0fdb2f928d1459f8b8180455491a1f937ce84e12f6a7d3e
sha512sums = c4da1e72c90534a5a1f7625b819dc2529fa5b91c8423550ca4384ec243bddd026b977d5f81660114f054ce8f64cd90057f6482f89df4af443f35da1871202c1d
sha512sums = d3789f0ecd354468f2e24d98501041430ae99c173320fa9c3eb02f225c08ed298fd1ad259e4ad9bb70b6ae89d84cd87460aaa720de3486d40b30777a8fe45453

pkgname = tensorflow-rocm
pkgdesc = Library for computation using data flow graphs for scalable machine learning (with ROCM)
Expand Down
89 changes: 48 additions & 41 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pkgname=()
[ "$_build_no_opt" -eq 1 ] && pkgname+=(tensorflow-rocm python-tensorflow-rocm)
[ "$_build_opt" -eq 1 ] && pkgname+=(tensorflow-opt-rocm python-tensorflow-opt-rocm)

pkgver=2.15.0
_pkgver=2.15.0
pkgrel=8
pkgver=2.17.0
_pkgver=2.17.0
pkgrel=1
pkgdesc="Library for computation using data flow graphs for scalable machine learning"
url="https://www.tensorflow.org/"
license=('APACHE')
Expand All @@ -25,16 +25,16 @@ depends=('c-ares' 'pybind11' 'openssl' 'libpng' 'curl' 'giflib' 'icu' 'libjpeg-t
'intel-oneapi-compiler-shared-runtime-libs')
makedepends=('bazel' 'python-numpy' 'rocm-hip-sdk' 'roctracer' 'rccl' 'git' 'miopen' 'python-wheel' 'openmp'
'python-installer' 'python-setuptools' 'python-h5py' 'python-keras-applications'
'python-keras-preprocessing' 'cython' 'patchelf' 'python-requests' 'libxcrypt-compat' 'clang'
'jdk11-openjdk')
'python-keras-preprocessing' 'cython' 'patchelf' 'python-requests' 'libxcrypt-compat' 'clang')
optdepends=('tensorboard: Tensorflow visualization toolkit')
source=("$pkgname-$pkgver.tar.gz::https://github.com/tensorflow/tensorflow/archive/v${_pkgver}.tar.gz"
https://github.com/bazelbuild/bazel/releases/download/6.1.0/bazel_nojdk-6.1.0-linux-x86_64
fix-c++17-compat.patch)

sha512sums=('51976c7255ffbdb98fe67a28f6ae1c3b9a073e49fe6b44187a53d99654e4af753de53bfa7229cdd1997ac71e8ddecbc15e4759d46c6d24b55eb84c5d31523dfe'
'b71aed83ae1c3f610df77f7c148703fd3e7aa5901794a2b31c6044c71b3f030831d59f7f3641992105117a422655160fc9b509326b31586c6bca378cbff08762'
'f682368bb47b2b022a51aa77345dfa30f3b0d7911c56515d428b8326ee3751242f375f4e715a37bb723ef20a86916dad9871c3c81b1b58da85e1ca202bc4901e')
tensorflow-2.16.1-python-distutils-removal.patch
tensorflow-numpy2.patch
https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel_nojdk-6.5.0-linux-x86_64)
sha512sums=('45061f075971cf2bc219a34b1cda2ee9851ba586e94046838e6e1fd26adcfb399d90e71e89a0f709d5282ff3be7cc3a82b81d62dce53db5010640ea41487a469'
'e4c44d2f5314b83d8ed404e5ec14960ef8b7df0c1a2a3e826f913a02c901f9fd0326f9014a602121e0fdb2f928d1459f8b8180455491a1f937ce84e12f6a7d3e'
'c4da1e72c90534a5a1f7625b819dc2529fa5b91c8423550ca4384ec243bddd026b977d5f81660114f054ce8f64cd90057f6482f89df4af443f35da1871202c1d'
'd3789f0ecd354468f2e24d98501041430ae99c173320fa9c3eb02f225c08ed298fd1ad259e4ad9bb70b6ae89d84cd87460aaa720de3486d40b30777a8fe45453')

# consolidate common dependencies to prevent mishaps
_common_py_depends=(python-termcolor python-astor python-gast python-numpy python-protobuf
Expand Down Expand Up @@ -70,11 +70,21 @@ check_dir() {
prepare() {
# Since Tensorflow is currently imcompatible with our version of Bazel, we're going to use
# their exact version of Bazel to fix that. Stupid problems call for stupid solutions.
install -Dm755 "${srcdir}"/bazel_nojdk-6.1.0-linux-x86_64 bazel/bazel
PATH="/usr/lib/jvm/java-11-openjdk/bin:$PATH"
install -Dm755 "${srcdir}"/bazel_nojdk-6.5.0-linux-x86_64 bazel/bazel
export PATH="${srcdir}/bazel:$PATH"
bazel --version

# Python 3.12 removed the distutils module
# https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/issues/7
# patch -Np1 -i ../tensorflow-numpy2.patch -d tensorflow-${_pkgver}
# cd tensorflow-${_pkgver}/ci/official/requirements_updater
# ./updater.sh
# cd -

# Python 3.12 removed the distutils module
# https://gitlab.archlinux.org/archlinux/packaging/packages/tensorflow/-/issues/7
patch -Np1 -i ../tensorflow-2.16.1-python-distutils-removal.patch -d tensorflow-${_pkgver}

# Get rid of hardcoded versions. Not like we ever cared about what upstream
# thinks about which versions should be used anyway. ;) (FS#68772)
sed -i -E "s/'([0-9a-z_-]+) .= [0-9].+[0-9]'/'\1'/" tensorflow-${_pkgver}/tensorflow/tools/pip_package/setup.py
Expand Down Expand Up @@ -132,7 +142,7 @@ prepare() {
export PYTHON_BIN_PATH=/usr/bin/python$(get_pyver)
export USE_DEFAULT_PYTHON_LIB_PATH=1

export BAZEL_ARGS="--config=mkl -c opt"
export BAZEL_ARGS="-c opt --verbose_failures --config=verbose_logs --copt=-Wno-gnu-offsetof-extensions"
}

build() {
Expand All @@ -144,31 +154,31 @@ build() {
export TF_NEED_ROCM=1
./configure
bazel \
build \
build --config=rocm \
${BAZEL_ARGS[@]} \
//tensorflow:libtensorflow.so \
//tensorflow:libtensorflow_cc.so \
//tensorflow:libtensorflow_framework.so \
//tensorflow:install_headers \
//tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package --src "${srcdir}"/tmprocm-src --dst "${srcdir}"/tmprocm --rocm
//tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow
fi


if [ "$_build_opt" -eq 1 ]; then
echo "Building with rocm and with non-x86-64 optimizations"
cd "${srcdir}"/tensorflow-${_pkgver}-opt-rocm
export CC_OPT_FLAGS="-march=haswell -O3"
export CC_OPT_FLAGS="-march=haswell -O2"
export TF_NEED_CUDA=0
export TF_NEED_ROCM=1
./configure
bazel \
build --config=avx_linux \
build --config=opt --config=avx_linux --config=rocm \
${BAZEL_ARGS[@]} \
//tensorflow:libtensorflow.so \
//tensorflow:libtensorflow_cc.so \
//tensorflow:libtensorflow_framework.so \
//tensorflow:install_headers \
//tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package --src "${srcdir}"/tmpoptrocm-src --dst "${srcdir}"/tmpoptrocm --rocm
//tensorflow/tools/pip_package:wheel --repo-env=WHEEL_NAME=tensorflow
fi
}

Expand All @@ -178,7 +188,7 @@ _package() {
cp -r bazel-bin/tensorflow/include/* "${pkgdir}"/usr/include/tensorflow/

# install python-version to get all extra headers
WHEEL_PACKAGE=$(find "${srcdir}"/$1 -name "tensor*.whl")
WHEEL_PACKAGE=$(find -L bazel-out -name "tensor*.whl")
python -m installer --destdir="$pkgdir" $WHEEL_PACKAGE

# move extra headers to correct location
Expand All @@ -199,29 +209,25 @@ _package() {
ldd "${_so_file}" &>/dev/null && rm -rf "${_so_file}"
done

# install the rest of tensorflow
# pkgconfig
tensorflow/c/generate-pc.sh --prefix=/usr --version=${pkgver}
sed -e 's@/include$@/include/tensorflow@' -i tensorflow.pc -i tensorflow_cc.pc
install -Dm644 tensorflow.pc "${pkgdir}"/usr/lib/pkgconfig/tensorflow.pc
install -Dm644 tensorflow_cc.pc "${pkgdir}"/usr/lib/pkgconfig/tensorflow_cc.pc
install -Dm755 bazel-bin/tensorflow/libtensorflow.so "${pkgdir}"/usr/lib/libtensorflow.so.${pkgver}
ln -s libtensorflow.so.${pkgver} "${pkgdir}"/usr/lib/libtensorflow.so.${pkgver:0:1}
ln -s libtensorflow.so.${pkgver:0:1} "${pkgdir}"/usr/lib/libtensorflow.so
install -Dm755 bazel-bin/tensorflow/libtensorflow_cc.so "${pkgdir}"/usr/lib/libtensorflow_cc.so.${pkgver}
ln -s libtensorflow_cc.so.${pkgver} "${pkgdir}"/usr/lib/libtensorflow_cc.so.${pkgver:0:1}
ln -s libtensorflow_cc.so.${pkgver:0:1} "${pkgdir}"/usr/lib/libtensorflow_cc.so
install -Dm755 bazel-bin/tensorflow/libtensorflow_framework.so "${pkgdir}"/usr/lib/libtensorflow_framework.so.${pkgver}
ln -s libtensorflow_framework.so.${pkgver} "${pkgdir}"/usr/lib/libtensorflow_framework.so.${pkgver:0:1}
ln -s libtensorflow_framework.so.${pkgver:0:1} "${pkgdir}"/usr/lib/libtensorflow_framework.so

# .so files
rm bazel-bin/tensorflow/*.params
cp -P bazel-bin/tensorflow/*.so* "${pkgdir}"/usr/lib

# C API headers
install -Dm644 tensorflow/c/c_api.h "${pkgdir}"/usr/include/tensorflow/tensorflow/c/c_api.h
install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE

# Fix interoperability of C++14 and C++17. See https://bugs.archlinux.org/task/65953
patch -Np0 -i "${srcdir}"/fix-c++17-compat.patch -d "${pkgdir}"/usr/include/tensorflow/absl/base
# license
install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

_python_package() {
WHEEL_PACKAGE=$(find "${srcdir}"/$1 -name "tensor*.whl")
WHEEL_PACKAGE=$(find -L bazel-ouot -name "tensor*.whl")
python -m installer --destdir="$pkgdir" $WHEEL_PACKAGE

# create symlinks to headers
Expand All @@ -236,7 +242,7 @@ _python_package() {
# tensorboard has been separated from upstream but they still install it with
# tensorflow. I don't know what kind of sense that makes but we have to clean
# it out from this pacakge.
rm -rf "${pkgdir}"/usr/bin/tensorboard
rm -r "${pkgdir}"/usr/bin/tensorboard

install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
Expand All @@ -248,7 +254,7 @@ package_tensorflow-rocm() {
provides=(tensorflow)

cd "${srcdir}"/tensorflow-${_pkgver}-rocm
_package tmprocm
_package
}

package_tensorflow-opt-rocm() {
Expand All @@ -258,7 +264,7 @@ package_tensorflow-opt-rocm() {
provides=(tensorflow tensorflow-rocm)

cd "${srcdir}"/tensorflow-${_pkgver}-opt-rocm
_package tmpoptrocm
_package
}

package_python-tensorflow-rocm() {
Expand All @@ -268,7 +274,7 @@ package_python-tensorflow-rocm() {
provides=(python-tensorflow)

cd "${srcdir}"/tensorflow-${_pkgver}-rocm
_python_package tmprocm
_python_package
}

package_python-tensorflow-opt-rocm() {
Expand All @@ -278,7 +284,8 @@ package_python-tensorflow-opt-rocm() {
provides=(python-tensorflow python-tensorflow-rocm)

cd "${srcdir}"/tensorflow-${_pkgver}-opt-rocm
_python_package tmpoptrocm
_python_package
}

# vim:set ts=2 sw=2 et:

11 changes: 0 additions & 11 deletions fix-c++17-compat.patch

This file was deleted.

84 changes: 84 additions & 0 deletions tensorflow-2.16.1-python-distutils-removal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
diff --git a/tensorflow/api_template.__init__.py b/tensorflow/api_template.__init__.py
index a0f88926..9c0bb098 100644
--- a/tensorflow/api_template.__init__.py
+++ b/tensorflow/api_template.__init__.py
@@ -27,7 +27,6 @@ this file with a file generated from [`api_template.__init__.py`](https://www.gi
"""
# pylint: disable=g-bad-import-order,protected-access,g-import-not-at-top

-import distutils as _distutils
import importlib
import inspect as _inspect
import os as _os
@@ -95,10 +94,10 @@ _site_packages_dirs = []
if _site.ENABLE_USER_SITE and _site.USER_SITE is not None:
_site_packages_dirs += [_site.USER_SITE]
_site_packages_dirs += [p for p in _sys.path if "site-packages" in p]
-if "getsitepackages" in dir(_site):
+try:
_site_packages_dirs += _site.getsitepackages()
-
-if "sysconfig" in dir(_distutils):
+except AttributeError:
+ import distutils as _distutils
_site_packages_dirs += [_distutils.sysconfig.get_python_lib()]

_site_packages_dirs = list(set(_site_packages_dirs))
diff --git a/tensorflow/api_template_v1.__init__.py b/tensorflow/api_template_v1.__init__.py
index 6a4ab4e6..d6f8f2e0 100644
--- a/tensorflow/api_template_v1.__init__.py
+++ b/tensorflow/api_template_v1.__init__.py
@@ -14,7 +14,6 @@
# ==============================================================================
"""Bring in all of the public TensorFlow interface into this module."""

-import distutils as _distutils
import importlib
import inspect as _inspect
import os as _os
@@ -144,10 +143,10 @@ from tensorflow.python.lib.io import file_io as _fi
_site_packages_dirs = []
_site_packages_dirs += [] if _site.USER_SITE is None else [_site.USER_SITE]
_site_packages_dirs += [p for p in _sys.path if "site-packages" in p]
-if "getsitepackages" in dir(_site):
+try:
_site_packages_dirs += _site.getsitepackages()
-
-if "sysconfig" in dir(_distutils):
+except AttributeError:
+ import distutils as _distutils
_site_packages_dirs += [_distutils.sysconfig.get_python_lib()]

_site_packages_dirs = list(set(_site_packages_dirs))
diff --git a/tensorflow/lite/python/convert.py b/tensorflow/lite/python/convert.py
index cfaff27a..a4eeb02f 100644
--- a/tensorflow/lite/python/convert.py
+++ b/tensorflow/lite/python/convert.py
@@ -14,7 +14,6 @@
# ==============================================================================
"""Converts a frozen graph into a TFLite FlatBuffer."""

-import distutils.spawn
import enum
import hashlib
import os as _os
@@ -45,6 +44,10 @@ from tensorflow.python.platform import resource_loader as _resource_loader
from tensorflow.python.util import deprecation
from tensorflow.python.util.tf_export import tf_export as _tf_export

+try:
+ from shutil import which
+except ImportError:
+ from distutils.spawn import find_executable as which

def _is_quantized_input_stats_required(
conversion_flags: _conversion_flags_pb2.TocoFlags,
@@ -399,7 +402,7 @@ def _run_deprecated_conversion_binary(
RuntimeError: When conversion fails, an exception is raised with the error
message embedded.
"""
- if distutils.spawn.find_executable(_deprecated_conversion_binary) is None:
+ if which(_deprecated_conversion_binary) is None:
raise ConverterError("""Could not find `toco_from_protos` binary, make sure
your virtualenv bin directory or pip local bin directory is in your path.
In particular, if you have installed TensorFlow with --user, make sure you
35 changes: 35 additions & 0 deletions tensorflow-numpy2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/ci/official/requirements_updater/requirements.in b/ci/official/requirements_updater/requirements.in
index 5c5892b2..0ee2eea0 100644
--- a/ci/official/requirements_updater/requirements.in
+++ b/ci/official/requirements_updater/requirements.in
@@ -1,6 +1,6 @@
# TODO(b/304751256): Adjust the numpy pin to a single version, when ready
numpy ~= 1.23.5 ; python_version <= "3.11"
-numpy ~= 1.26.0 ; python_version >= "3.12"
+numpy ~= 2.0.0 ; python_version >= "3.12"
wheel ~= 0.41.2
h5py >= 3.10.0
lit ~= 17.0.2
@@ -25,7 +25,8 @@ tensorboard ~= 2.17.0
# Test dependencies
grpcio >= 1.24.3, < 2.0
portpicker == 1.6.0
-scipy == 1.11.3
+scipy == 1.11.3 ; python_version <= "3.11"
+scipy == 1.14.0 ; python_version >= "3.12"
requests == 2.31.0
packaging==23.2
setuptools==68.2.2
diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py
index 88da8b54..e4041765 100644
--- a/tensorflow/tools/pip_package/setup.py
+++ b/tensorflow/tools/pip_package/setup.py
@@ -86,7 +86,7 @@ REQUIRED_PACKAGES = [
'ml_dtypes >= 0.3.1, < 0.5.0',
# TODO(b/304751256): Adjust the numpy pin to a single version, when ready
'numpy >= 1.23.5, < 2.0.0 ; python_version <= "3.11"',
- 'numpy >= 1.26.0, < 2.0.0 ; python_version >= "3.12"',
+ 'numpy ~= 2.0.0 ; python_version >= "3.12"',
'opt_einsum >= 2.3.2',
'packaging',
# pylint:disable=line-too-long

0 comments on commit fa64355

Please sign in to comment.