# Copyright Yahoo. 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 13 %define ver_patch 1 %define ver_release 6 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 Patch0: patches.use-origin-rpath-for-jni-library.diff Patch1: patches.include.cstdint.diff Patch2: patches.disable-gcc-13-warnings-for-flatbuffers.diff Patch3: patches.external-pytorch-cpuinfo-src-arm-linux-init.diff BuildRequires: ccache BuildRequires: vespa-gradle BuildRequires: which %if 0%{?el8} %define _devtoolset_enable /opt/rh/gcc-toolset-11/enable BuildRequires: gcc-toolset-11-gcc-c++ BuildRequires: make BuildRequires: glibc-langpack-en BuildRequires: wget BuildRequires: cmake %define _cmake_prog cmake %define _ctest_prog ctest %global _enable_cuda 1 %endif %if 0%{?el9} BuildRequires: gcc-c++ BuildRequires: make BuildRequires: glibc-langpack-en BuildRequires: cmake %define _cmake_prog cmake %define _ctest_prog ctest %ifarch x86_64 %global _enable_cuda 1 %endif %endif %if 0%{?fedora} BuildRequires: gcc-c++ BuildRequires: make BuildRequires: cmake BuildRequires: glibc-langpack-en %define _cmake_prog cmake %define _ctest_prog ctest %endif BuildRequires: zlib-devel %if ! 0%{?el9} && ! 0%{?amzn2023} BuildRequires: redhat-lsb-core %endif BuildRequires: expat-devel BuildRequires: libcurl-devel BuildRequires: python3-devel BuildRequires: python3-numpy %if ! 0%{?el9} BuildRequires: libunwind %endif BuildRequires: python3-setuptools BuildRequires: bzip2 %if 0%{?_enable_cuda:1} BuildRequires: cuda-libraries-devel-11-8 BuildRequires: cuda-compiler-11-8 BuildRequires: cuda-cudart-devel-11-8 BuildRequires: cuda-command-line-tools-11-8 BuildRequires: libcudnn8 = 8.9.4.25-1.cuda11.8 BuildRequires: libcudnn8-devel = 8.9.4.25-1.cuda11.8 BuildRequires: libcublas-devel-11-8 BuildRequires: libcurand-devel-11-8 BuildRequires: libcufft-devel-11-8 %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 %patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 %if 0%{?_download_cmake_tar} # Download precompiled cmake version on CentOS 7, RHEL 7 and Amazon Linux 2 for now. if test -f %{cmake_prog} then : else wget -O /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v%{_cmake_version}/cmake-%{_cmake_version}-Linux-%{_arch}.tar.gz tar xf /tmp/cmake.tar.gz rm -f /tmp/cmake.tar.gz fi %endif %build %if 0%{?_devtoolset_enable:1} source %{_devtoolset_enable} || true %endif PATH=%{_prefix}/bin:$PATH %if 0%{?_enable_cuda:1} %global _enable_cuda_options --use_cuda --cuda_home=/usr/local/cuda-11.8 --cudnn_home=/usr %global _enable_cuda_extra_defines CMAKE_CUDA_ARCHITECTURES="60;70;75" %endif ./build.sh \ --config RelWithDebInfo \ %{?_enable_cuda_options:%{_enable_cuda_options}} \ --skip_tests \ --build_java \ --build_shared_lib \ --parallel \ --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_DEV_MODE=OFF \ onnxruntime_USE_OPENMP=OFF \ %{?_toolset_compiler_cmake_args} %install rm -rf $RPM_BUILD_ROOT %if 0%{?_devtoolset_enable:1} source %{_devtoolset_enable} || true %endif 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/. # Compat links with tarfile distribution ln -s core/session/onnxruntime_c_api.h %{buildroot}%{_prefix}/include/onnxruntime/onnxruntime_c_api.h ln -s core/session/onnxruntime_cxx_api.h %{buildroot}%{_prefix}/include/onnxruntime/onnxruntime_cxx_api.h ln -s core/session/onnxruntime_cxx_inline.h %{buildroot}%{_prefix}/include/onnxruntime/onnxruntime_cxx_inline.h %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: libcufft-11-8 Requires: libcublas-11-8 Requires: libcurand-11-8 Requires: libcudnn8 = 8.9.4.25-1.cuda11.8 %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