# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. # Disable build id note requirement for now %undefine _missing_build_ids_terminate_build # Force special prefix for Vespa %define _prefix /opt/vespa-deps # Only strip debug info %global _find_debuginfo_opts -g # Don't provide shared library or pkgconfig %global __provides_exclude ^(lib.*\\.so(\\.[0-9.]*)?\\([A-Z._0-9]*\\)\\(64bit\\)|pkgconfig\\(.*)$ %global __requires_exclude ^libonnxruntime\\.so\\.[0-9.]*\\([A-Z._0-9]*\\)\\(64bit\\)$ # Version %define ver_major 1 %define ver_minor 19 %define ver_patch 2 %define ver_release 1 Summary: ONNX Runtime package for Vespa Name: vespa-onnxruntime Version: %{ver_major}.%{ver_minor}.%{ver_patch} Release: %{ver_release}%{?dist} License: MIT License URL: https://microsoft.github.io/onnxruntime Source0: vespa-onnxruntime-%{version}.tar.gz Source1: patches.external-pytorch-cpuinfo-src-arm-linux-init.diff Patch0: patches.use-origin-rpath-for-jni-library.diff Patch1: patches.no-array-bounds.diff Patch2: patches.use-gradle.diff Patch3: patches.apply-cpuinfo.diff Patch4: patches.onnxruntime-core-providers-cpu-ml-tree-ensemble-aggregator.diff Patch5: patches.test-clip-float16.diff Patch6: patches.num-limits-float16.diff %if 0%{?fedora} && !0%{?amzn} BuildRequires: cmake %else BuildRequires: vespa-cmake %endif %define _cmake_prog cmake %define _ctest_prog ctest BuildRequires: ccache BuildRequires: vespa-gradle BuildRequires: which %if 0%{?el8} %define _devtoolset_enable /opt/rh/gcc-toolset-12/enable BuildRequires: vespa-toolset-12-meta BuildRequires: gcc-toolset-12-dwz BuildRequires: vespa-gtest BuildRequires: make BuildRequires: glibc-langpack-en BuildRequires: wget BuildRequires: python39 BuildRequires: python39-devel BuildRequires: python39-numpy BuildRequires: python39-setuptools %global _enable_cuda 1 %define _cudnn_version 8.9.4.25-1.cuda12.2 %endif %if 0%{?el9} %define _devtoolset_enable /opt/rh/gcc-toolset-12/enable BuildRequires: vespa-toolset-12-meta BuildRequires: gcc-toolset-12-dwz BuildRequires: gtest-devel BuildRequires: make BuildRequires: glibc-langpack-en BuildRequires: python3 BuildRequires: python3-devel BuildRequires: python3-numpy BuildRequires: python3-setuptools %global _enable_cuda 1 %define _cudnn_version 8.9.6.50-1.cuda12.2 %endif %if 0%{?fedora} BuildRequires: gcc-c++ BuildRequires: make BuildRequires: glibc-langpack-en %endif BuildRequires: zlib-devel %if ! 0%{?el9} && ! 0%{?amzn2023} BuildRequires: redhat-lsb-core %endif BuildRequires: expat-devel BuildRequires: libcurl-devel %if ! 0%{?el9} BuildRequires: libunwind %endif BuildRequires: bzip2 %if 0%{?_enable_cuda:1} BuildRequires: cuda-libraries-devel-12-2 BuildRequires: cuda-compiler-12-2 BuildRequires: cuda-cudart-devel-12-2 BuildRequires: cuda-command-line-tools-12-2 BuildRequires: libcudnn8-devel = %{_cudnn_version} %endif %description ONNX Runtime package for Vespa. See https://github.com/vespa-engine/vespa-3rdparty-deps for details about packaging. %package devel Summary: ONNX Runtime dev package for Vespa. Requires: %{name} = %{version}-%{release} %description devel %{version} dev package for Vespa. See https://github.com/vespa-engine/vespa-3rdparty-deps for details about packaging. %prep %setup -q %patch -P 0 -p1 %patch -P 1 -p1 %patch -P 2 -p0 %patch -P 3 -p1 %patch -P 4 -p0 %patch -P 5 -p1 %patch -P 6 -p1 mkdir cmake/patches/pytorch_cpuinfo cp -a %{SOURCE1} cmake/patches/pytorch_cpuinfo/arm-linux-init.diff %build %if 0%{?_devtoolset_enable:1} source %{_devtoolset_enable} %endif PATH=%{_prefix}/bin:$PATH %if 0%{?_enable_cuda:1} %global _enable_cuda_options --use_cuda --cuda_home=/usr/local/cuda-12.2 --cudnn_home=/usr %global _enable_cuda_extra_defines CMAKE_CUDA_ARCHITECTURES="60;70;75" %endif if [ -f /usr/bin/python3.9 ]; then sed -i 's=^python3 =python3.9 =' build.sh fi ./build.sh \ --allow_running_as_root \ --config RelWithDebInfo \ %{?_enable_cuda_options:%{_enable_cuda_options}} \ --skip_tests \ --build_java \ --build_shared_lib \ --parallel 6 \ --cmake_path %{_cmake_prog} \ --ctest_path %{_ctest_prog} \ --skip_submodule_sync \ --cmake_extra_defines \ CMAKE_INSTALL_PREFIX=%{_prefix} \ CMAKE_CXX_COMPILER_LAUNCHER=ccache \ %{?_enable_cuda_extra_defines:%{_enable_cuda_extra_defines}} \ onnxruntime_USE_OPENMP=OFF \ %{?_toolset_compiler_cmake_args} %install rm -rf $RPM_BUILD_ROOT %if 0%{?_devtoolset_enable:1} source %{_devtoolset_enable} %endif PATH=%{_prefix}/bin:$PATH make -C build/Linux/RelWithDebInfo DESTDIR=%{buildroot} install cp -p build/Linux/RelWithDebInfo/lib*jni*.so* %{buildroot}%{_prefix}/lib64/. mkdir -p %{buildroot}%{_prefix}/lib cp -p build/Linux/RelWithDebInfo/java/build/libs/* %{buildroot}%{_prefix}/lib/. %files %{_prefix}/lib64/ %if 0%{?_enable_cuda:1} %exclude %{_prefix}/lib64/*cuda* %endif %exclude %{_prefix}/bin/ %license LICENSE %files devel %{_prefix}/include/ %license LICENSE %package java Summary: ONNX java runtime support for Vespa. Requires: %{name} = %{version}-%{release} %description java %{version} java support package for Vespa. See https://github.com/vespa-engine/vespa-3rdparty-deps for details about packaging. %files java %{_prefix}/lib/ %license LICENSE %if 0%{?_enable_cuda:1} %package cuda Summary: ONNX provider for CUDA (for Vespa). Requires: %{name} = %{version}-%{release} Requires: cuda-cudart-12-2 Requires: libcufft-12-2 Requires: libcublas-12-2 Requires: libcurand-12-2 Requires: libcudnn8 = %{_cudnn_version} %description cuda CUDA support package for Vespa. See https://github.com/vespa-engine/vespa-3rdparty-deps for details about packaging. %files cuda %{_prefix}/lib64/*cuda* %license LICENSE %endif %changelog