# enable tests by default # you may want to disable tests if running outside mock, # since they will depend on your hardware and software, # and sometimes fail due to that %bcond check 1 # Where the backends are located is distro-specific # they are NOT public APIs/ABIs so we can put them wherever # also note that libggml-base.so is also non-public # see: https://github.com/ggml-org/ggml/issues/1405 %global ggml_backend_dir %{_libdir}/libggml-private # arch-specific conditionals # Note: The rocm conditional just switches the hip backend on or off %ifarch x86_64 %bcond rocm 1 %else %bcond rocm 0 %endif # Third-Party Backends are parameterized so that we can easily disable # misbehaving ones and isolate issues. (CPU Backend is always enabled!) %bcond blas 1 %bcond hip %{with rocm} %bcond opencl 1 %bcond vulkan 1 # TODO: Additional features and backends # - CUDA for x86_64 and aarch64 (in RPMFusion? with a free CUDA impl?) # - KelidiAI on aarch64 # - zenDNN on x86_64 # - zDNN on s390x # TODO: Name/Provides? ggml? GGML? libggml? libGGML? # TODO: usefulness of separate subpackages for backends? Name: ggml Version: 0.9.5 Release: 1%{?dist} Summary: Tensor library for machine learning License: MIT URL: https://ggml.ai/ Source0: https://github.com/ggml-org/ggml/archive/refs/tags/v%{version}.tar.gz # Base/CPU BuildRequires: cmake BuildRequires: gcc BuildRequires: gcc-c++ # Third-Party Backends # BLAS %if %{with blas} BuildRequires: flexiblas-devel %endif # ROCm/HIP %if %{with hip} BuildRequires: hipblas-devel BuildRequires: rocblas-devel BuildRequires: rocm-hip-devel BuildRequires: rocm-rpm-macros %endif # OpenCL %if %{with opencl} BuildRequires: opencl-headers BuildRequires: OpenCL-ICD-Loader-devel BuildRequires: python3 %endif # Vulkan %if %{with vulkan} BuildRequires: glslc BuildRequires: vulkan-headers BuildRequires: vulkan-loader-devel %endif # For now, require the CPU backend and recommend the others # TODO: Since OpenCL isn't a default package, maybe loosen that rec? Requires: %{name}-cpu%{?_isa} = %{version}-%{release} %if %{with blas} Recommends: %{name}-blas%{?_isa} = %{version}-%{release} %endif %if %{with hip} Recommends: %{name}-hip%{?_isa} = %{version}-%{release} %endif %if %{with opencl} Recommends: %{name}-opencl%{?_isa} = %{version}-%{release} %endif %if %{with vulkan} Recommends: %{name}-vulkan%{?_isa} = %{version}-%{release} %endif %description Tensor library for machine learning Features: - Low-level cross-platform implementation - Integer quantization support - Broad hardware support - Automatic differentiation - ADAM and L-BFGS optimizers - No third-party dependencies - Zero memory allocations during runtime %package cpu Summary: CPU backend for ggml Requires: %{name}%{?_isa} = %{version}-%{release} %description cpu The CPU backend for libggml. %if %{with blas} %package blas Summary: BLAS backend for ggml Requires: %{name}%{?_isa} = %{version}-%{release} # TODO runtime deps %description blas The BLAS backend for libggml. %endif %if %{with hip} %package hip Summary: ROCm/HIP backend for ggml Requires: %{name}%{?_isa} = %{version}-%{release} # TODO runtime deps %description hip The ROCm/HIP backend for libggml. %endif %if %{with opencl} %package opencl Summary: OpenCL backend for ggml Requires: %{name}%{?_isa} = %{version}-%{release} # TODO runtime deps %description opencl The OpenCL backend for libggml. %endif %if %{with vulkan} %package vulkan Summary: Vulkan backend for ggml Requires: %{name}%{?_isa} = %{version}-%{release} # TODO runtime deps %description vulkan The Vulkan backend for libggml. %endif %package devel Summary: Development files for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} %description devel The %{name}-devel package contains libraries and header files for developing applications that use %{name}. %prep %autosetup %build # Don't optimize for this specific CPU # Build libggml as a shared library, dynamically linking backends # Build the (built-in) CPU backend, with all known arches # Build the other ("third-party") backends, optionally # Build the tests, optionally # Do not build the examples %cmake \ -DGGML_NATIVE:BOOL=OFF \ -DBUILD_SHARED_LIBS:BOOL=ON \ -DGGML_BACKEND_DL:BOOL=ON \ -DGGML_BACKEND_DIR:PATH="%{ggml_backend_dir}" \ -DGGML_CPU:BOOL=ON \ -DGGML_CPU_ALL_VARIANTS:BOOL=ON \ -DGGML_BLAS:BOOL=%{?with_blas:ON}%{!?with_blas:OFF} \ -DGGML_BLAS_VENDOR:STRING="FlexiBLAS" \ -DGGML_HIP:BOOL=%{?with_hip:ON}%{!?with_hip:OFF} \ -DAMDGPU_ARCHITECTURES:STRING=%{?with_hip:%rocm_gpu_list_default} \ -DGGML_OPENCL:BOOL=%{?with_opencl:ON}%{!?with_opencl:OFF} \ -DGGML_VULKAN:BOOL=%{?with_vulkan:ON}%{!?with_vulkan:OFF} \ -DGGML_BUILD_TESTS:BOOL=%{?with_check:ON}%{!?with_check:OFF} \ -DGGML_BUILD_EXAMPLES:BOOL=OFF %cmake_build %install %cmake_install %check %if %{with check} %ctest %endif %files %license LICENSE AUTHORS %doc README.md docs/ %{_libdir}/libggml.so.* %{_libdir}/libggml-base.so # per ggml#1405 the soversion on base is not really important # base is private and really shouldn't be versioned? # then maybe it shouldn't be in libdir? %{_libdir}/libggml-base.so.* %dir %{ggml_backend_dir} %files cpu %{ggml_backend_dir}/libggml-cpu*.so %if %{with blas} %files blas %{ggml_backend_dir}/libggml-blas.so %endif %if %{with hip} %files hip %{ggml_backend_dir}/libggml-hip.so %endif %if %{with opencl} %files opencl %{ggml_backend_dir}/libggml-opencl.so %endif %if %{with vulkan} %files vulkan %{ggml_backend_dir}/libggml-vulkan.so %endif %files devel %{_includedir}/ggml*.h %{_includedir}/gguf.h %{_libdir}/libggml.so %dir %{_libdir}/cmake/ggml %{_libdir}/cmake/ggml/ggml-config.cmake %{_libdir}/cmake/ggml/ggml-version.cmake %{_datadir}/pkgconfig/ggml.pc %changelog %autochangelog