File tensorflow2.spec of Package tensorflow2
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
#
%define pname tensorflow2
%define vers 2.7.1
#%%define cand -rc4
%define _vers 2_7_1
%define libmaj 2
%define libmin 7
%define libref 1
%ifarch aarch64
%define mklconfig mkl_aarch64
%else
%define mklconfig mkl
%endif
%global flavor @BUILD_FLAVOR@%{nil}
# Build tensorflow, not Tensorflow-lite
%define is_lite 0
%if "%{flavor}" == "standard"
%bcond_with cuda
%bcond_with mpi
%bcond_with opencl
%endif
%if "%{flavor}" == "lite"
%define is_lite 1
%bcond_with cuda
%bcond_with mpi
%bcond_with opencl
%define package_suffix -lite
# https://en.opensuse.org/openSUSE:LTO#Static_libraries
%global _lto_cflags %{?_lto_cflags} -ffat-lto-objects
%endif
%if "%{flavor}" == "hpc"
%bcond_with cuda
%bcond_with mpi
%bcond_with opencl
%bcond_without hpc
%define compiler_family gnu
%endif
%if "%{flavor}" == "hpc-openmpi2"
%define mpi_flavor openmpi
%define mpi_vers 2
%bcond_with cuda
%bcond_without mpi
%bcond_with opencl
%bcond_without hpc
%define compiler_family gnu
%endif
%if "%{flavor}" == "hpc-mvapich2"
%define mpi_flavor mvapich2
%bcond_with cuda
%bcond_without mpi
%bcond_with opencl
%bcond_without hpc
%define compiler_family gnu
%endif
%if "%{flavor}" == "cuda-10-1"
%bcond_without cuda
%bcond_with mpi
%bcond_with opencl
%endif
%if "%{flavor}" == "opencl"
%bcond_without opencl
%bcond_with cuda
%bcond_with mpi
%endif
%if %{with hpc}
%{!?compiler_family:%global compiler_family gnu}
%{hpc_init -c %compiler_family %{?with_mpi:-m %mpi_flavor} %{?c_f_ver:-v %{c_f_ver}} %{?mpi_ver:-V %{mpi_ver}} %{?ext:-e %{ext}}}
%{?with_mpi:%global hpc_module_pname p%{pname}}
# hpc macros expect this, but we do not use the python-rpm-macros subpackage rewriter
%define python_flavor python3
%define package_name %{hpc_package_name %_vers}
%define package_name_provide tensorflow2%{hpc_package_name_tail}
%define package_name_conflict tensorflow%{hpc_package_name_tail}
%define libname(l:s:) lib%{pname}%{-l*}%{hpc_package_name_tail %{?_vers}}
%define package_python_sitearch %hpc_python_sitearch
%define package_prefix %hpc_prefix
%define package_bindir %hpc_bindir
%define package_libdir %hpc_libdir
%define package_includedir %hpc_includedir
%else
%define package_name %pname%{?package_suffix}
%define package_name_conflict tensorflow%{?package_suffix}
%define package_python_sitearch %{python3_sitearch}
%define package_prefix %_prefix
%define package_bindir %_bindir
%define package_libdir %_libdir
%define package_includedir %_includedir
%define libname(l:s:) lib%{pname}%{!-l:%{-s:-}}%{-l*}%{-s*}%{?package_suffix}
%endif
Name: %{package_name}
Version: %vers
Release: 0
Summary: A framework used for deep learning
License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND FSFUL AND MIT AND MPL-2.0 AND OpenSSL AND Python-2.0
Group: Development/Languages/Python
URL: https://www.tensorflow.org/
Source0: https://github.com/tensorflow/tensorflow/archive/v%{version}%{?cand}.tar.gz#/tensorflow-%{version}.tar.gz
# IMPORTANT
# although some of the following libraries are available in factory they could
# not be used as
# * explicit versions are needed which differ from the factory ones
# * bazel and the obs version have different symbols due to hidden compiler flags
# License10: Apache-2.0
Source10: https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz#/rules_closure.tar.gz
# License15: MIT
Source15: https://github.com/google/farmhash/archive/0d859a811870d10f53a594927d0d0b97573ad06d.tar.gz#/farmhash.tar.gz
# License17: Apache-2.0
Source17: https://github.com/google/gemmlowp/archive/fda83bdc38b118cc6b56753bd540caa49e570745.zip#/gemmlowp.zip
# License18: BSD-3-Clause
Source18: https://github.com/hfp/libxsmm/archive/1.14.tar.gz#/libxsmm_1.14.tar.gz
# License19: Apache-2.0
Source19: https://github.com/abseil/abseil-cpp/archive/997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz#/abseil-cpp.tar.gz
# License21: Apache-2.0
Source21: https://github.com/googleapis/googleapis/archive/541b1ded4abadcc38e8178680b0677f65594ea6f.zip#/googleapis.zip
# License24: Apache-2.0
Source24: https://github.com/google/highwayhash/archive/fd3d9af80465e4383162e4a7c5e2f406e82dd968.tar.gz#/highwayhash.tar.gz
# License26: MPL-2.0
# NOTE: tensorflow only uses MPL-2.0 part of eigen
Source26: https://gitlab.com/libeigen/eigen/-/archive/7792b1e909a98703181aecb8810b4b654004c25d/eigen-7792b1e909a98703181aecb8810b4b654004c25d.tar.gz#/eigen.tar.gz
# License27: BSD-2-Clause
Source27: https://github.com/intel/ARM_NEON_2_x86_SSE/archive/1200fe90bb174a6224a525ee60148671a786a71f.tar.gz#/arm_neon_2_x86_sse.tar.gz
# License30: Apache-2.0
Source30: https://github.com/grpc/grpc/archive/b54a5b338637f92bfcf4b0bc05e0f57a5fd8fadd.tar.gz#/grpc.tar.gz
# License31: Apache-2.0
Source31: https://github.com/envoyproxy/data-plane-api/archive/c83ed7ea9eb5fb3b93d1ad52b59750f1958b8bde.tar.gz#/envoyproxy.tar.gz
# License32: BSD-3-Clause
Source32: https://github.com/protocolbuffers/upb/archive/9effcbcb27f0a665f9f345030188c0b291e32482.tar.gz#/upb.tar.gz
# License35: Apache-2.0
Source35: https://github.com/googleapis/google-cloud-cpp/archive/v1.17.1.tar.gz#/google-cloud-cpp.tar.gz
# License37: Apache-2.0
Source37: https://github.com/bazelbuild/rules_docker/releases/download/v0.18.0/rules_docker-v0.18.0.tar.gz#/rules_docker-0.18.0.tar.gz
# License44: BSD like
Source44: https://github.com/nanopb/nanopb/archive/f8ac463766281625ad710900479130c7fcb4d63b.tar.gz#/nanopb.tar.gz
# License45: Python license itself, do need as sha256b have to match so could not use system one
Source45: https://storage.googleapis.com/mirror.tensorflow.org/docs.python.org/2.7/_sources/license.rst.txt#/python-license.txt
# License46: Another python2 license:
Source46: https://raw.githubusercontent.com/simonpercivall/astunparse/v1.6.2/LICENSE#/python-license-astunparse
# Deps sources for Tensorflow-Lite (use same eigen, gemmlowp and abseil_cpp packages as non lite version)
# License52: Apache-2.0
Source52: https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz#/flatbuffers.tar.gz
# License53: BSD like
Source53: https://storage.googleapis.com/mirror.tensorflow.org/github.com/petewarden/OouraFFT/archive/v1.0.tar.gz#/fft2d.tgz
# License54: Apache-2.0 WITH LLVM-exception OR NCSA
Source54: https://github.com/llvm/llvm-project/archive/43d6991c2a4cc2ac374e68c029634f2b59ffdfdf.tar.gz#/llvm.tar.gz
# License56: BSD-3-Clause
Source56: https://github.com/mborgerding/kissfft/archive/36dbc057604f00aacfc0288ddad57e3b21cfc1b8.tar.gz#/kissfft.tar.gz
# Wrong rules package in Factory
# License58: Apache-2.0
Source58: https://github.com/bazelbuild/rules_cc/archive/40548a2974f1aea06215272d9c2b47a14a24e556.tar.gz#/rules_cc.tar.gz
# Source59: Apache-2.0
Source59: https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_android/archive/v0.1.1.zip#/rules_android.zip
# License60: BSD 2-Clause
Source60: https://storage.googleapis.com/mirror.tensorflow.org/github.com/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.zip#/cpuinfo.zip
# License61: BSD 2-Clause
Source61: https://github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz#/clog.tar.gz
# License23: BSD-3-Clause
Source62: https://github.com/joe-kuo/sobol_data/archive/835a7d7b1ee3bc83e575e302a985c66ec4b65249.tar.gz#/sobol_data.tar.gz
# Source63: Apache-2.0
Source63: https://github.com/google/ruy/archive/e6c1b8dc8a8b00ee74e7268aac8b18d7260ab1ce.zip#/ruy.zip
# License64: Apache-2.0
Source64: https://github.com/dmlc/dlpack/archive/3efc489b55385936531a06ff83425b719387ec63.tar.gz#/dlpack.tar.gz
# License65: BSD like
Source65: https://github.com/petewarden/OouraFFT/archive/v1.0.tar.gz#/DouraFFT.tar.gz
# License66: BSD-3-Clause
# Factory version does not work
Source66: https://github.com/google/re2/archive/506cfa4bffd060c06ec338ce50ea3468daa6c814.tar.gz#/re2.tar.gz
# License67: Apache-2.0 WITH LLVM-exception OR NCSA
Source67: https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/openmp-10.0.1.src.tar.xz
# License69: BSD-2-Clause
Source69: https://files.pythonhosted.org/packages/d3/41/901ef2e81d7b1e834b9870d416cb09479e175a2be1c4aa1a9dcd0a555293/tblib-1.7.0.tar.gz
# License70: BSD-3-Clause
Source70: https://files.pythonhosted.org/packages/e2/96/518a8ea959a734b70d2e95fef98bcbfdc7adad1c1e5f5dd9148c835205a5/dill-0.3.2.zip
# License71: PSF
Source71: https://files.pythonhosted.org/packages/6a/28/d32852f2af6b5ead85d396249d5bdf450833f3a69896d76eb480d9c5e406/typing_extensions-3.7.4.2.tar.gz
# License72: Apache License 2.0
Source72: https://github.com/tensorflow/toolchains/archive/v1.2.7.tar.gz#/tf_toolchains.tar.gz
# License73: Apache License 2.0
Source73: https://github.com/tensorflow/runtime/archive/64c92c8013b557087351c91b5423b6046d10f206.tar.gz#/tf_runtime.tar.gz
# License74: MIT
Source74: https://github.com/ARM-software/ComputeLibrary/archive/v21.08.tar.gz#/ComputeLibrary.tar.gz
# License75: Apache License 2.0
Source75: https://github.com/bazelbuild/platforms/releases/download/0.0.2/platforms-0.0.2.tar.gz
# License76: Apache License 2.0
Source76: https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz#/rules_proto.tar.gz
# MKL selects different versions of oneDNN for arm than for intel
# License77: Apache License 2.0
Source77: https://github.com/oneapi-src/oneDNN/archive/v2.4.tar.gz#/oneDNN-2.4.tar.gz
# License78: Apache License 2.0
Source78: https://github.com/oneapi-src/oneDNN/archive/v2.4.1.tar.gz#/oneDNN.tar.gz
# License79: BSD-3-Clause
Source79: https://github.com/google/XNNPACK/archive/694d2524757f9040e65a02c374e152a462fe57eb.zip#/xnnpack.zip
# transitive tensorflow-lite dependencies for xnnpack
# NOTE: the github url is non-deterministic for the following zipfile archives (!?) Content is the same, but the hashes of the zipfiles differ.
# License80: MIT
# Source80: https://github.com/Maratyszcza/FP16/archive/4dfe081cf6bcd15db339cf2680b9281b8451eeb3.zip #/FP16.zip
Source80: FP16.zip
# License81: MIT
# Source81: https://github.com/Maratyszcza/FXdiv/archive/b408327ac2a15ec3e43352421954f5b1967701d1.zip #/FXdiv.zip
Source81: FXdiv.zip
# License82: BSD-2-Clause
# Source82: https://github.com/Maratyszcza/pthreadpool/archive/545ebe9f225aec6dca49109516fac02e973a3de2.zip #/pthreadpool.zip
Source82: pthreadpool.zip
# License83: MIT
# Source83: https://github.com/Maratyszcza/psimd/archive/072586a71b55b7f8c584153d223e95687148a900.zip #/psimd.zip
Source83: psimd.zip
Patch10: tensorflow-2.6.0-removed-external-toolchains.patch
# PATCH-FIX-UPSTREAM tensorflow-2.7.0-fix-lite.patch -- https://github.com/tensorflow/tensorflow/commit/fb1dcbd9 + gh#tensorflow/tensorflow#54216
Patch11: tensorflow-2.7.0-fix-lite.patch
# PATCH-FIX-OPENSUSE tensorflow-2.7.0-go_host_sdk.patch -- grpc_extra_deps pulls in go, use system SDK instead of downloading a binary blob
Patch12: tensorflow-2.7.0-go_host_sdk.patch
# PATCH-FIX-OPENSUSE tensorflow-2.6.0-compile-with-protobuf-3.16.patch https://github.com/protocolbuffers/protobuf/pull/8354
Patch23: tensorflow-2.6.0-compile-with-protobuf-3.16.patch
%if !%{is_lite}
# See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/pip_package/setup.py
Requires: python3 >= 3.7
Requires: python3-Keras-Preprocessing >= 1.1.1
Requires: python3-absl-py >= 0.4.0
Requires: python3-astunparse >= 1.6.0
Requires: python3-gast >= 0.2.1
Requires: python3-google-pasta >= 0.1.1
Requires: python3-h5py >= 2.9.0
# Upstream uses the PyPI libclang package, which bundles libclang, but we can use our system libclang with the official bindings
Requires: python3-clang >= 9.0.1
Requires: python3-numpy >= 1.14.5
Requires: python3-opt-einsum >= 2.3.2
Requires: python3-protobuf >= 3.9.2
Requires: python3-six >= 1.12.0
# TODO: not available, actually optional, see buildrequires and prep section below
#Requires: python3-tensorflow-io-gcs-filesystem >= 0.21.0
Requires: python3-termcolor >= 1.1.0
Requires: python3-typing_extensions >= 3.6.6
Requires: python3-wrapt >= 1.11.0
Requires: (python3-flatbuffers >= 1.12 with python3-flatbuffers < 3)
Requires: (python3-keras >= 2.7.0 with python3-keras < 2.8)
Requires: (python3-tensorboard >= 2.6 with python3-tensorboard < 2.7)
Requires: (python3-tensorflow_estimator >= 2.7.0 with python3-tensorflow_estimator < 2.8)
Requires: (python3-wheel >= 0.32.0 with python3-wheel < 1.0)
%if %{with hpc}
Requires: python3-numpy-%{compiler_family}%{?c_f_ver}-hpc
%else
Requires: python3-numpy
%endif
Requires: python3-pip
%endif
%if !%{is_lite}
%if %{with hpc}
Provides: python3-tensorflow-%{compiler_family}%{?c_f_ver}-hpc
%else
Provides: python3-tensorflow
%endif
Provides: tensorflow
%endif
%if !%{is_lite}
BuildRequires: bazel == 3.7.2
#BuildRequires: bazel-rules-cc-source
BuildRequires: bazel-apple-support-source
BuildRequires: bazel-rules-apple-source
BuildRequires: bazel-rules-go-source
BuildRequires: bazel-rules-java-source
BuildRequires: bazel-rules-proto-source
BuildRequires: bazel-rules-python-source
BuildRequires: bazel-rules-swift-source
BuildRequires: bazel-skylib-source >= 1.0.3
BuildRequires: bazel-toolchains-source
BuildRequires: bazel-workspaces
#BuildRequires: bazel-rules-foreign-cc-source
%else
BuildRequires: cmake
%endif
BuildRequires: curl
%if %{with cuda}
BuildRequires: cuda-compiler-10-1
BuildRequires: cuda-cufft-dev-10-1
BuildRequires: cuda-cupti-10-1
BuildRequires: cuda-curand-dev-10-1
BuildRequires: cuda-cusolver-dev-10-1
BuildRequires: cuda-cusparse-dev-10-1
BuildRequires: cuda-libraries-10-1
BuildRequires: libcublas-devel
BuildRequires: libcudnn7-devel
BuildRequires: libnccl-devel
%endif
%if %{with opencl}
Requires: Mesa-libOpenCL
BuildRequires: opencl-cpp-headers
BuildRequires: opencl-headers
%endif
BuildRequires: boringssl-devel
BuildRequires: curl-devel
BuildRequires: double-conversion-devel >= 3.1.5
BuildRequires: fdupes
BuildRequires: fftw3-devel
BuildRequires: flatbuffers-devel
BuildRequires: giflib-devel
BuildRequires: git
BuildRequires: go
%if 0%{?suse_version} > 1500 && %{with cuda}
# use gcc-7 for build with cuda, as nvcc can not handle
# gcc9
BuildRequires: gcc7
BuildRequires: gcc7-c++
%endif
BuildRequires: jemalloc-devel
BuildRequires: jsoncpp-devel
BuildRequires: libicu-devel
BuildRequires: libjpeg-devel
BuildRequires: libjpeg-turbo
BuildRequires: libjpeg62-devel
BuildRequires: libnsync-devel
BuildRequires: libpng16-compat-devel
BuildRequires: libpng16-devel
BuildRequires: lmdb-devel
BuildRequires: memory-constraints
BuildRequires: nasm
BuildRequires: openssl-devel
# Requiring 3.9.1 which is the actual one in Leap 15.2
BuildRequires: protobuf-devel >= 3.9.1
BuildRequires: protobuf-java
BuildRequires: python-pybind11-common-devel
BuildRequires: python3
BuildRequires: python3-Cython
# We use same macros here but not singlespec
BuildRequires: python-rpm-macros
%if !%{is_lite}
BuildRequires: python3 >= 3.7
BuildRequires: python3-Keras-Preprocessing >= 1.1.1
BuildRequires: python3-absl-py >= 0.4.0
BuildRequires: python3-astunparse >= 1.6.0
BuildRequires: python3-clang >= 9.0.1
BuildRequires: python3-gast >= 0.2.1
BuildRequires: python3-google-pasta >= 0.1.1
BuildRequires: python3-h5py >= 2.9.0
BuildRequires: python3-numpy >= 1.14.5
BuildRequires: python3-numpy-devel >= 1.14.5
BuildRequires: python3-opt-einsum >= 2.3.2
BuildRequires: python3-pip
BuildRequires: python3-protobuf >= 3.9.2
BuildRequires: python3-six >= 1.12.0
# TODO: not available, will create circular dependency, see also prep section below
#BuildRequires: python3-tensorflow-io-gcs-filesystem >= 0.21.0
BuildRequires: python3-termcolor >= 1.1.0
BuildRequires: python3-typing_extensions >= 3.6.6
BuildRequires: python3-wrapt >= 1.11.0
BuildRequires: (python3-flatbuffers >= 1.12 with python3-flatbuffers < 3)
BuildRequires: (python3-keras >= 2.7.0 with python3-keras < 2.8)
BuildRequires: (python3-tensorboard >= 2.6 with python3-tensorboard < 2.7)
BuildRequires: (python3-tensorflow_estimator >= 2.7.0 with python3-tensorflow_estimator < 2.8)
BuildRequires: (python3-wheel >= 0.32.0 with python3-wheel < 1.0)
%endif
BuildRequires: snappy-devel
BuildRequires: sqlite3-devel
BuildRequires: swig
BuildRequires: unzip
BuildRequires: zlib-devel
%if %{with hpc}
%hpc_requires
BuildRequires: %{compiler_family}%{?c_f_ver}-compilers-hpc-macros-devel
BuildRequires: lua-lmod
BuildRequires: suse-hpc
%if %{with mpi}
BuildRequires: %{mpi_flavor}%{?mpi_vers}-%{compiler_family}%{?c_f_ver}-hpc-macros-devel
%endif
%endif
%if %{with hpc}
Provides: %{package_name_provide}
%endif
Conflicts: %{package_name_conflict}
# just use rpmlint
# there are some serious compiler warnings, regarding no-return-in-nonvoid-function
#!BuildRequires: -post-build-checks
%if "%flavor" == ""
ExclusiveArch: do_not_build
%endif
%if %{is_lite}
ExcludeArch: %ix86
%else
ExcludeArch: %ix86 %arm
%endif
%description
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
%{?with_hpc:%{hpc_master_package -a -L}}
%package -n %{package_name}-devel
Summary: Header files of tensorflow
Group: Development/Languages/Python
Requires: %{package_name} = %{version}
%if %{with hpc}
Provides: %{package_name_provide}-devel
%endif
Conflicts: %{package_name_conflict}-devel
%if !%{is_lite}
Requires: libtensorflow%{libmaj}%{?hpc_package_name_tail} = %{version}
Requires: libtensorflow_cc%{libmaj}%{?hpc_package_name_tail} = %{version}
Requires: libtensorflow_framework%{libmaj}%{?hpc_package_name_tail} = %{version}
Requires: python(abi) = %python3_version
%endif
%description -n %{package_name}-devel
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
This package provides necessary headers for the C/C++ Api
%package -n %{package_name}-doc
Summary: Examples from the tensorflow website
Group: Documentation/Other
Requires: %{package_name} = %{version}
%description -n %{package_name}-doc
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
This package provides examples from the website.
%package -n libtensorflow%{libmaj}%{?hpc_package_name_tail}
Summary: Shared library for tensorflow
Group: Libraries
%description -n libtensorflow%{libmaj}%{?hpc_package_name_tail}
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
%package -n libtensorflow_cc%{libmaj}%{?hpc_package_name_tail}
Summary: Shared library for tensorflow
Group: Libraries
%description -n libtensorflow_cc%{libmaj}%{?hpc_package_name_tail}
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
%package -n libtensorflow_framework%{libmaj}%{?hpc_package_name_tail}
Summary: Shared library for tensorflow
Group: Libraries
%description -n libtensorflow_framework%{libmaj}%{?hpc_package_name_tail}
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
%ifarch x86_64
%package -n libiomp5%{?hpc_package_name_tail}
Summary: Shared library for tensorflow
Group: Libraries
%description -n libiomp5%{?hpc_package_name_tail}
This open source software library for numerical computation is used for data
flow graphs. The graph nodes represent mathematical operations, while the graph
edges represent the multidimensional data arrays (tensors) that flow between
them. This flexible architecture enables you to deploy computation to one or
more CPUs in a desktop, server, or mobile device without rewriting code.
%endif
%prep
# fighting bazel. Use _builddir in order to keep it between `osc --stage=...` calls but have it cleaned for regular builds
%define bazeldir %{_builddir}/BAZEL
mkdir -p %{bazeldir}
%define bazeltoolchains %{_builddir}/bazel-toolchains
# macro for copying the files to the bazel cache dir, so that we do not download things
%define bz_cachdir %{_builddir}/BAZEL_CACHE
%define makebazelcache() mkdir -p %{bz_cachdir}/content_addressable/sha256/%{?2:%2}%{?!2:$(sha256sum %1 | cut -f 1 -d ' ')}/; cp %1 %{bz_cachdir}/content_addressable/sha256/%{?2:%2}%{?!2:$(sha256sum %1 | cut -f 1 -d ' ')}/file ;
%makebazelcache %{SOURCE10}
%makebazelcache %{SOURCE15}
%makebazelcache %{SOURCE17}
%makebazelcache %{SOURCE18}
%makebazelcache %{SOURCE19}
%makebazelcache %{SOURCE21}
%makebazelcache %{SOURCE24}
%makebazelcache %{SOURCE26}
%makebazelcache %{SOURCE27}
%makebazelcache %{SOURCE30}
%makebazelcache %{SOURCE31}
%makebazelcache %{SOURCE32}
%makebazelcache %{SOURCE35}
%makebazelcache %{SOURCE44}
%makebazelcache %{SOURCE45}
%makebazelcache %{SOURCE46}
%makebazelcache %{SOURCE53}
%makebazelcache %{SOURCE54}
%makebazelcache %{SOURCE56}
%makebazelcache %{SOURCE58}
%makebazelcache %{SOURCE59}
%makebazelcache %{SOURCE60}
%makebazelcache %{SOURCE61}
%makebazelcache %{SOURCE62}
%makebazelcache %{SOURCE63}
%makebazelcache %{SOURCE64}
%makebazelcache %{SOURCE65}
%makebazelcache %{SOURCE66}
%makebazelcache %{SOURCE67}
%makebazelcache %{SOURCE69}
%makebazelcache %{SOURCE70}
%makebazelcache %{SOURCE71}
%makebazelcache %{SOURCE72}
%makebazelcache %{SOURCE73}
%makebazelcache %{SOURCE74}
%makebazelcache %{SOURCE75}
%makebazelcache %{SOURCE76}
%makebazelcache %{SOURCE77}
%makebazelcache %{SOURCE78}
%makebazelcache %{SOURCE79}
%define make_depend_src() test -e $(basename %{1}| sed 's/-.*//') && rmdir %{?2}%{!?2:$(basename %{1}| sed 's/-.*//')}; test -e %{2} && rmdir %{2}; tar xzf %{1}; mv $(basename %{1} | sed 's/\.tar\.gz//' ) %{?2}%{!?2:$(basename %{1}| sed 's/-.*//')}
# extract bazel rules
pushd %{bazeldir}
%make_depend_src %{S:37}
popd
# unpack tensorflow
%setup -q -n tensorflow-%{version}
%patch10 -p 1
%patch11 -p 1
%patch12 -p 1
# https://github.com/protocolbuffers/protobuf/pull/8354
if pkg-config --atleast-version 3.16.0 protobuf; then
%patch23 -p 1
fi
# fighting upstream's crazy dependency declaration:
# https://github.com/conda-forge/tensorflow-feedstock/pull/176
# https://github.com/tensorflow/tensorflow/pull/51460
# TODO: Check if this is still optional after the next upgrade!
sed -i '/tensorflow-io-gcs-filesystem/d' tensorflow/tools/pip_package/setup.py
# remove shebang
sed -i '1{/env python/d}' tensorflow/lite/tools/visualize.py
%if %{is_lite}
# prepare third-party sources for CMake tensorflow-lite build. Source81 through 83 are transitive dependencies of FP16
unzip %{SOURCE60} -d third_party/cpuinfo
tar xf %{SOURCE61} -C third_party/clog
unzip %{SOURCE80} -d third_party/FP16
unzip %{SOURCE81} -d third_party/FP16
unzip %{SOURCE82} -d third_party/FP16
unzip %{SOURCE83} -d third_party/FP16
%endif
%build
%if %{is_lite}
# --- Build tensorflow-lite as part of the minimal executable ---
mkdir tflite-minimal
pushd tflite-minimal
%cmake ../../tensorflow/lite/examples/minimal \
-DBUILD_STATIC_LIBS:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DOVERRIDABLE_FETCH_CONTENT_farmhash_URL=%{SOURCE15} \
-DOVERRIDABLE_FETCH_CONTENT_gemmlowp_URL=%{SOURCE17} \
-DOVERRIDABLE_FETCH_CONTENT_abseil-cpp_URL=%{SOURCE19} \
-DOVERRIDABLE_FETCH_CONTENT_eigen_URL=%{SOURCE26} \
-DINCLUDE_INSTALL_DIR:PATH=include/eigen3 \
-DOVERRIDABLE_FETCH_CONTENT_neon2sse_URL=%{SOURCE27} \
-DOVERRIDABLE_FETCH_CONTENT_flatbuffers_URL=%{SOURCE52} \
-DOVERRIDABLE_FETCH_CONTENT_fft2d_URL=%{SOURCE53} \
-DOVERRIDABLE_FETCH_CONTENT_ruy_URL=%{SOURCE63} \
-DOVERRIDABLE_FETCH_CONTENT_xnnpack_URL=%{SOURCE79} \
-DCPUINFO_SOURCE_DIR:PATH=$(realpath ../../third_party/cpuinfo/cpuinfo-*) \
-DCLOG_SOURCE_DIR:PATH=$(realpath ../../third_party/clog/cpuinfo-*) \
-DFP16_SOURCE_DIR:PATH=$(realpath ../../third_party/FP16/FP16-*) \
-DFXDIV_SOURCE_DIR:PATH=$(realpath ../../third_party/FP16/FXdiv-*) \
-DPTHREADPOOL_SOURCE_DIR:PATH=$(realpath ../../third_party/FP16/pthreadpool-*) \
-DPSIMD_SOURCE_DIR:PATH=$(realpath ../../third_party/FP16/psimd-*) \
%ifarch %arm aarch64
-DTFLITE_ENABLE_XNNPACK:BOOL=OFF \
%endif
%{nil}
%cmake_build
popd
%else
# --- Build regular tensorflow (standard and hpc) ---
%limit_build -m 6000
%if %{with hpc}
%hpc_setup
module load gnu
%if %{with mpi}
module load %mpi_flavor
export MPI_HOME=${MPI_HOME:-$MPI_DIR}
%endif
%endif
cp -r /usr/src/bazel-toolchains %{bazeltoolchains}
export TEST_TMPDIR=%{bazeldir}
export PYTHON_LIB_PATH=%{python3_sitearch}
export PYTHON_BIN_PATH=/usr/bin/python3
export CC_OPT_FLAGS=-O2
export TF_NEED_JEMALLOC=0
export TF_NEED_GCP=0
export TF_NEED_HDFS=1
export TF_NEED_S3=1
export TF_ENABLE_XLA=0
export TF_NEED_VERBS=0
export TF_NEED_OPENCL=0
export TF_NEED_ROCM=0
export TF_SYSTEM_LIBS="\
absl_py,\
astor_archive,\
astunparse_archive,\
boringssl,\
com_github_googlecloudplatform_google_cloud_cpp,\
com_google_protobuf,\
curl,\
cython,\
double_conversion,\
enum34_archive,\
flatbuffers,\
functools32_archive,\
gast_archive,\
gif,\
hwloc,\
icu,\
libjpeg_turbo,\
jsoncpp_git,\
lmdb,\
nasm,\
nsync,\
opt_einsum_archive,\
org_sqlite,\
pasta,\
png,\
pybind11,\
six_archive,\
snappy,\
termcolor_archive,\
wrapt,\
zlib"
#com_googlesource_code_re2,\
%if %{with cuda}
export PATH=PATH="/usr/local/cuda-10.1/bin/:${PATH}"
export CUDA_HOME="/usr/local/cuda-10.1,/usr"
export CUDA_TOOLKIT_PATH=/"usr/local/cuda-10.1,/usr"
export TF_CUDA_PATHS="/usr/local/cuda-10.1,/usr"
export TF_NEED_CUDA=1
export TF_NCCL_VERSION=2.7.3
%else
export TF_NEED_CUDA=0
%endif
%if %{with mpi}
export TF_NEED_MPI=1
%else
export TF_NEED_MPI=0
%endif
export TF_NEED_KAFKA=1
export TF_NEED_GDR=0
%if %{with opencl}
export TF_NEED_OPENCL_SYCL=1
%else
export TF_NEED_OPENCL_SYCL=0
%endif
export TF_DOWNLOAD_CLANG=0
export ANDROID_NDK_HOME=0
# force the use python3
mkdir %{_topdir}/bin
cd %{_topdir}/bin
ln -s $(which python3) python
%if 0%{?suse_version} > 1500 && %{with cuda}
ln -s $(which gcc-7) gcc
ln -s $(which g++-7) g++
%endif
export PATH=%{_topdir}/bin/:${PATH}
cd -
./configure
%define bazelopts \\\
-s -c opt \\\
--repository_cache=%{bz_cachdir} \\\
--ignore_unsupported_sandboxing \\\
--verbose_failures \\\
--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" \\\
--config=%{mklconfig} \\\
--config=nonccl \\\
--config=v2 \\\
--config=noaws \\\
--override_repository="bazel_skylib=/usr/src/bazel-skylib" \\\
--override_repository="bazel_toolchains=%{bazeltoolchains}" \\\
--override_repository="rules_java=/usr/src/bazel-rules-java" \\\
--override_repository="rules_python=/usr/src/bazel-rules-python" \\\
--override_repository="io_bazel_rules_docker=%{bazeldir}/rules_docker" \\\
--override_repository="io_bazel_rules_go=/usr/src/bazel-rules-go" \\\
--override_repository="build_bazel_rules_apple=/usr/src/bazel-rules-apple" \\\
--override_repository="build_bazel_apple_support=/usr/src/bazel-apple-support" \\\
--override_repository="build_bazel_rules_swift=/usr/src/bazel-rules-swift" \\\
--jobs %{?jobs} \\\
%{nil}
# --override_repository="upb=/usr/share/bazel-workspaces/upb" \\\
# --override_repository="rules_cc=/usr/src/bazel-rules-cc" \\\
bazel build %{bazelopts} tensorflow/tools/pip_package:build_pip_package
mkdir -p wheelhouse
bazel-bin/tensorflow/tools/pip_package/build_pip_package $PWD/wheelhouse
# Generate protobuf (for armNN) - https://github.com/ARM-software/armnn/blob/branches/armnn_19_08/scripts/generate_tensorflow_protobuf.sh
export OUTPUT_DIR=./pb/
mkdir -p $OUTPUT_DIR
for i in `find -name *.proto`; do
protoc $i \
--proto_path=. \
--proto_path=%{_includedir} \
--cpp_out=$OUTPUT_DIR
done
bazel build \
%bazelopts \
//tensorflow:libtensorflow.so
bazel build \
%bazelopts \
//tensorflow:libtensorflow_cc.so
bazel build \
%bazelopts \
//tensorflow:libtensorflow_framework.so
bazel build \
%bazelopts \
--config opt //tensorflow/tools/lib_package:libtensorflow
# end of !is_lite build
%endif
%install
%if %{is_lite}
# --- Install tensorflow-lite ---
pushd tflite-minimal/build
install -D minimal %{buildroot}%{_bindir}/tflite_minimal
install -D tensorflow-lite/libtensorflow-lite.a %{buildroot}%{_libdir}/libtensorflow-lite.a
# Disable spurious-executable-perm
chmod -x %{buildroot}%{_libdir}/libtensorflow-lite.a
popd
for file in `find tensorflow/lite -name \*.h`; do
# Package header files - boo#1175099
install -D $file %{buildroot}%{_includedir}/$file
# Disable spurious-executable-perm
chmod -x %{buildroot}%{_includedir}/$file
done
install -D tensorflow/lite/schema/schema.fbs %{buildroot}%{_includedir}/tensorflow/lite/schema/schema.fbs
chmod -x %{buildroot}%{_includedir}/tensorflow/lite/schema/schema.fbs
install -D tensorflow/core/public/version.h %{buildroot}%{_includedir}/tensorflow/core/public/version.h
chmod -x %{buildroot}%{_includedir}/tensorflow/core/public/version.h
# Install tensorflow-lite.pc
mkdir -p %{buildroot}%{_libdir}/pkgconfig
cat <<EOF > %{buildroot}%{_libdir}/pkgconfig/tensorflow-lite.pc
Name: tensorflow lite
Description: tensorflow lite static library
Version: %{vers}
Libs: -L%{_libdir} -ltensorflow-lite -lflatbuffers
Cflags: -I%{_includedir}
EOF
# Some tools expect tensorflow2-lite.pc
pushd %{buildroot}%{_libdir}/pkgconfig
ln -s tensorflow-lite.pc tensorflow2-lite.pc
popd
%else
# --- Intall regular tensorflow (standard and hpc) ---
pip install wheelhouse/tensorflow-*.whl --root=%{buildroot}%{?hpc_prefix} \
--no-warn-script-location --no-index --no-deps --no-compile
# install lib package
tar -xzf bazel-bin/tensorflow/tools/lib_package/libtensorflow.tar.gz -C %{buildroot}%{?hpc_prefix}/%{_prefix}
if [ "%{_libdir}" != "%{_prefix}/lib" ]; then
mkdir -p %{buildroot}%{?hpc_prefix}/%{_libdir}
mv %{buildroot}%{?hpc_prefix}/%{_prefix}/lib/lib*.so* %{buildroot}%{?hpc_prefix}/%{_libdir}/
rmdir %{buildroot}%{?hpc_prefix}/%{_prefix}/lib
fi
mv %{buildroot}%{?hpc_prefix}/%{_prefix}/*LICENSE* ./
chmod -x *LICENSE*
# for hpc build remove usr prefix dir
%if %{with hpc}
cd %{buildroot}%{?hpc_prefix}
mv usr/* .
rmdir usr
cd -
%else
# Generate and install pkgconfig files for non-hpc - tensorflow.pc and tensorflow_cc.pc
sh tensorflow/c/generate-pc.sh --prefix=/usr --libdir %{_lib} --version %{vers}
mkdir -p %{buildroot}%{package_libdir}/pkgconfig
cp *.pc %{buildroot}%{package_libdir}/pkgconfig
%endif
# remove executable bits
find %{buildroot} -name \*.h -type f -exec chmod 644 {} +
find %{buildroot} -name LICENSE\* -type f -exec chmod 644 {} +
find %{buildroot}%{package_python_sitearch}/tensorflow/include -name \*.inc -type f -exec chmod 644 {} +
find %{buildroot}%{package_python_sitearch}/tensorflow/include -name \*.td -type f -exec chmod 644 {} +
find %{buildroot}%{package_python_sitearch}/tensorflow/include -name \*.txt -type f -exec chmod 644 {} +
# avoid rpmlint error hardlink-across-partition: use symlinks instead of hardlinks, because the deduplication is between _libdir and _includedir
%fdupes -s %{buildroot}%{?hpc_prefix}
# install cc lib after fdupes
cp -vd \
bazel-bin/tensorflow/libtensorflow_cc.so \
bazel-bin/tensorflow/libtensorflow_cc.so.%{libmaj} \
bazel-bin/tensorflow/libtensorflow_cc.so.%{libmaj}.%{libmin}.%{libref} \
%{buildroot}%{package_libdir}/
%ifarch x86_64
mv %{buildroot}/%{package_python_sitearch}/_solib_k8/_U_S_Sthird_Uparty_Smkl_Cmkl_Ulibs_Ulinux___Uexternal_Sllvm_Uopenmp/libiomp5.so %{buildroot}/%{package_libdir}/
# Fix symlink
pushd %{buildroot}%{package_python_sitearch}/tensorflow/include/external/llvm_openmp/
rm libiomp5.so
ln -s %{package_libdir}/libiomp5.so
popd
%endif
# write hpc module files
%if %{with hpc}
sitesearch_path=`python3 -c "import sysconfig as s; print(s.get_paths(vars={'platbase':'%{hpc_prefix}','base':'%{hpc_prefix}'}).get('platlib'))"`
%hpc_write_modules_files
#%%Module1.0#####################################################################
proc ModulesHelp { } {
puts stderr " "
puts stderr "This module loads the %{pname} built with the %{compiler_family} toolchain."
puts stderr "\nVersion %{version}\n"
}
module-whatis "Name: %{pname} built with %{compiler_family} toolchain"
module-whatis "Version: %{version}"
module-whatis "Category: runtime library"
module-whatis "Description: %{SUMMARY:0}"
module-whatis "URL: %{url}"
set version %{version}
prepend-path PATH %{hpc_prefix}/bin
prepend-path LD_LIBRARY_PATH %{hpc_prefix}/%_lib
prepend-path TENSORFLOWDIR %{hpc_prefix}
prepend-path PYTHONPATH ${sitesearch_path}
if [ expr [ module-info mode load ] || [module-info mode display ] ] {
if { ![is-loaded python3-numpy] } {
module load python3-numpy
}
}
%if %{with mpi}
if [ expr [ module-info mode load ] || [module-info mode display ] ] {
if { ![is-loaded %mpi_flavor] } {
module load %mpi_flavor
}
}
%endif
%{hpc_modulefile_add_pkgconfig_path}
EOF
%endif
# end of !is_lite install
%endif
%post -n libtensorflow%{libmaj}%{?hpc_package_name_tail} -p /sbin/ldconfig
%postun -n libtensorflow%{libmaj}%{?hpc_package_name_tail} -p /sbin/ldconfig
%post -n libtensorflow_cc%{libmaj}%{?hpc_package_name_tail} -p /sbin/ldconfig
%postun -n libtensorflow_cc%{libmaj}%{?hpc_package_name_tail} -p /sbin/ldconfig
%post -n libtensorflow_framework%{libmaj}%{?hpc_package_name_tail} -p /sbin/ldconfig
%postun -n libtensorflow_framework%{libmaj}%{?hpc_package_name_tail} -p /sbin/ldconfig
%if %{is_lite}
%files
# --- files for tensorflow-lite ---
%{package_bindir}/tflite_minimal
%files -n %{package_name}-devel
%{package_libdir}/libtensorflow-lite.a
%dir %{_includedir}/tensorflow/lite/
%{_includedir}/tensorflow/lite/*
%dir %{_includedir}/tensorflow/core/public/
%{_includedir}/tensorflow/core/public/version.h
%{package_libdir}/pkgconfig/*.pc
%else
%files
# --- files for tensorflow standard and hpc ---
%defattr(-,root,root,-)
%{package_bindir}/estimator_ckpt_converter
%{package_bindir}/saved_model_cli
%{package_bindir}/tensorboard
%{package_bindir}/tf_upgrade_v2
%{package_bindir}/tflite_convert
%{package_bindir}/toco*
%{package_bindir}/import_pb_to_tensorboard
%{package_python_sitearch}/tensorflow-%{version}*
%{package_python_sitearch}/tensorflow
%exclude %{package_python_sitearch}/tensorflow/include
%exclude %{package_python_sitearch}/tensorflow/xla_aot_runtime_src
%if %{with hpc}
%hpc_modules_files
%endif
%files -n %{package_name}-devel
%{package_python_sitearch}/tensorflow/include
%{package_python_sitearch}/tensorflow/xla_aot_runtime_src
%{package_includedir}/tensorflow/
%{package_libdir}/libtensorflow.so
%{package_libdir}/libtensorflow_cc.so
%{package_libdir}/libtensorflow_framework.so
%if %{without hpc}
%{package_libdir}/pkgconfig/*.pc
%endif
%files -n libtensorflow_framework%{libmaj}%{?hpc_package_name_tail}
%{package_libdir}/libtensorflow_framework.so.%{libmaj}*
%files -n libtensorflow_cc%{libmaj}%{?hpc_package_name_tail}
%{package_libdir}/libtensorflow_cc.so.%{libmaj}*
%files -n libtensorflow%{libmaj}%{?hpc_package_name_tail}
%{package_libdir}/libtensorflow.so.%{libmaj}*
%ifarch x86_64
%files -n libiomp5%{?hpc_package_name_tail}
%{package_libdir}/libiomp5.so
%endif
%files -n %{package_name}-doc
%license THIRD_PARTY_TF_C_LICENSES LICENSE
%endif
%changelog