removed ffmpeg and sed since core utills are already installed

fixed CMAKE_SYSTEM_PROCESSOR through rpm macros

added additional cmake options

partially added OpenVINO and added cmake options

changed opstions v1

added options openblas and openvino to whisper

add -n as name of subpackages

removed -n

fixed bug with description

added ccache as build dependacny

change cmake build to make_build

removed patch in setup

replace name of cpu with %{_build_cpu} should makeno diffrance

removed -DCMAKE_SYSTEM_NAME=Linux

removed -DCMAKE_BUILD_TYPE=Release and set spec to cd to build dir to cmake

fixed cmkae so build works (but not all prarmiters have been given)

added back aarch64

removed cmake options due to being checked in make

added av optiones and set them to be enabled

fixed build and setup partial install

fixed install for bin and devel

added back ffmpeg

removed patch
This commit is contained in:
Mohammadreza Hendiani 2024-05-30 20:28:46 +03:30
commit e8fb14b8b4
No known key found for this signature in database
GPG key ID: 95358B3D35244150
2 changed files with 126 additions and 115 deletions

View file

@ -1,62 +0,0 @@
From 62ce17eb08b838fd4ac78d7fc3ece57694aad32a Mon Sep 17 00:00:00 2001
From: Tom Rix <trix@redhat.com>
Date: Sat, 20 Jan 2024 08:00:46 -0500
Subject: [PATCH] Generalize install locations
On Fedora the install location is dependent on the arch
ex/ for x86_64 libraries install to /usr/lib64
So copy how llama-cpp does its install, replacing 'llama' with 'whisper'
in the cmake variables.
Signed-off-by: Tom Rix <trix@redhat.com>
---
CMakeLists.txt | 17 ++++++++++++-----
cmake/DefaultTargetOptions.cmake | 4 ++--
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 567a58d..01e64c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -549,12 +549,19 @@ set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "ggml.h;whisper.h")
include(GNUInstallDirs)
+set(WHISPER_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}
+ CACHE PATH "Location of header files")
+set(WHISPER_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}
+ CACHE PATH "Location of library files")
+set(WHISPER_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}
+ CACHE PATH "Location of binary files")
+
install(TARGETS ${TARGET}
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib/static
- RUNTIME DESTINATION bin
- RESOURCE DESTINATION bin
- PUBLIC_HEADER DESTINATION include
+ LIBRARY DESTINATION "${WHISPER_LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${WHISPER_LIB_INSTALL_DIR}/static"
+ RUNTIME DESTINATION "${WHISPER_BIN_INSTALL_DIR}"
+ RESOURCE DESTINATION "${WHISPER_BIN_INSTALL_DIR}"
+ PUBLIC_HEADER DESTINATION "${WHISPER_INCLUDE_INSTALL_DIR}"
)
#
diff --git a/cmake/DefaultTargetOptions.cmake b/cmake/DefaultTargetOptions.cmake
index b4e93e3..277b99e 100644
--- a/cmake/DefaultTargetOptions.cmake
+++ b/cmake/DefaultTargetOptions.cmake
@@ -12,6 +12,6 @@ target_compile_features(${TARGET}
set_target_properties(${TARGET}
PROPERTIES
EXPORT_COMPILE_COMMANDS ON
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
- INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
+ RUNTIME_OUTPUT_DIRECTORY "${WHISPER_BIN_INSTALL_DIR}"
+ INSTALL_RPATH "${WHISPER_LIB_INSTALL_DIR}"
)
--
2.43.0

View file

@ -1,6 +1,8 @@
# Some optional subpackages
%bcond_with examples
%bcond_with test
%bcond_with openblas
%bcond_with openvino
Summary: Port of OpenAI's Whisper model in C/C++
Name: whisper-cpp
@ -26,59 +28,63 @@ ExclusiveArch: x86_64 aarch64
BuildRequires: cmake >= 3.27
BuildRequires: clang
BuildRequires: coreutils
BuildRequires: sed
BuildRequires: git
BuildRequires: pkgconfig(ffmpeg)
BuildRequires: pkgconfig(ffmpeg-devel)
BuildRequires: ccache
BuildRequires: ffmpeg-free-devel
BuildRequires: pkgconfig(libavcodec)
BuildRequires: pkgconfig(libavformat)
BuildRequires: pkgconfig(libavdevice)
BuildRequires: pkgconfig(libavutil)
BuildRequires: pkgconfig(libavfilter)
BuildRequires: pkgconfig(libswscale)
BuildRequires: pkgconfig(libpostproc)
BuildRequires: pkgconfig(libswresample)
#Requires: ffmpeg
#Requires: ffmpeg-devel
Requires: /usr/bin/ffmpeg
Requires: pkgconfig(libavcodec)
Requires: pkgconfig(libavformat)
Requires: pkgconfig(libavdevice)
Requires: pkgconfig(libavutil)
Requires: pkgconfig(libavfilter)
Requires: pkgconfig(libswscale)
Requires: pkgconfig(libpostproc)
Requires: pkgconfig(libswresample)
# TODO: add openblas package
# TODO: add OPENVINO package
# TODO: add CLBLAST package
# TODO opencl, rocm, CoreML
# TODO bindings/go/* and add package
%global base_description \
High-performance inference of OpenAI's Whisper automatic speech \
recognition (ASR) model: \
\
* Plain C/C++ implementation without dependencies \
* Apple Silicon first-class citizen - optimized via ARM NEON, \
* Accelerate framework, Metal and Core ML \
* AVX intrinsics support for x86 architectures \
* VSX intrinsics support for POWER architectures \
* Mixed F16 / F32 precision \
* 4-bit and 5-bit integer quantization support \
* Zero memory allocations at runtime \
* Support for CPU-only inference \
* Efficient GPU support for NVIDIA \
* Partial OpenCL GPU support via CLBlast \
* OpenVINO Support \
* C-style API
%description
High-performance inference of OpenAI's Whisper automatic speech
recognition (ASR) model:
* Plain C/C++ implementation without dependencies
* Apple Silicon first-class citizen - optimized via ARM NEON,
Accelerate framework, Metal and Core ML
* AVX intrinsics support for x86 architectures
* VSX intrinsics support for POWER architectures
* Mixed F16 / F32 precision
* 4-bit and 5-bit integer quantization support
* Zero memory allocations at runtime
* Support for CPU-only inference
* Efficient GPU support for NVIDIA
* Partial OpenCL GPU support via CLBlast
* OpenVINO Support
* C-style API
%{base_description}
%package devel
Summary: Libraries and headers for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
High-performance inference of OpenAI's Whisper automatic speech
recognition (ASR) model:
* Plain C/C++ implementation without dependencies
* Apple Silicon first-class citizen - optimized via ARM NEON,
Accelerate framework, Metal and Core ML
* AVX intrinsics support for x86 architectures
* VSX intrinsics support for POWER architectures
* Mixed F16 / F32 precision
* 4-bit and 5-bit integer quantization support
* Zero memory allocations at runtime
* Support for CPU-only inference
* Efficient GPU support for NVIDIA
* Partial OpenCL GPU support via CLBlast
* OpenVINO Support
* C-style API
%{base_description}
%if %{with test}
%package test
@ -98,8 +104,26 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%{summary}
%endif
%if %{with openvino}
%package openvino
Summary: %{name} with openvino
Requires: %{name}%{?_isa} = openvino-%{version}-%{release}
%description openvino
%{summary}
%endif
%if %{with openblas}
%package openblas
Summary: %{name} with openblas
Requires: %{name}%{?_isa} = openblas-%{version}-%{release}
%description openblas
%{summary}
%endif
%prep
%autosetup -p1 -n whisper.cpp-%{version}
%autosetup -n whisper.cpp-%{version}
# verson the *.so
sed -i -e 's/POSITION_INDEPENDENT_CODE ON/POSITION_INDEPENDENT_CODE ON SOVERSION %{version}/' CMakeLists.txt
@ -109,41 +133,90 @@ find . -name '.gitignore' -exec rm -rf {} \;
%build
%cmake \
-DCMAKE_SYSTEM_NAME=ON
-DCMAKE_SYSTEM_PROCESSOR=%{_build_cpu} \
-DCMAKE_SYSTEM_NAME="Linux" \
-DCMAKE_BUILD_TYPE="Release" \
-DBUILD_SHARED_LIBS_DEFAULT=ON \
-DWHISPER_WASM_SINGLE_FILE=OFF \
-DWHISPER_ALL_WARNINGS_3RD_PARTY=ON \
-DWHISPER_SANITIZE_THREAD=OFF \
-DWHISPER_SANITIZE_ADDRESS=OFF \
-DWHISPER_SANITIZE_UNDEFINED=OFF \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_EXAMPLES=OFF \
-DWHISPER_NO_AVX=ON \
-DWHISPER_NO_AVX2=ON \
-DWHISPER_NO_FMA=ON \
-DWHISPER_NO_F16C=ON
%if %{with examples}
-DWHISPER_BUILD_EXAMPLES=ON
-DWHISPER_SDL2=ON \
-DWHISPER_FFMPEG=ON \
-DWHISPER_NO_AVX2=OFF \
-DWHISPER_NO_AVX512=OFF \
-DWHISPER_NO_AVX512_VBMI=OFF \
-DWHISPER_NO_AVX512_VNNI=OFF \
-DWHISPER_NO_FMA=OFF \
-DWHISPER_NO_F16C=OFF \
-DWHISPER_PERF=OFF \
%if %{with openvino}
-DWHISPER_OPENVINO=ON \
%else
-DWHISPER_BUILD_EXAMPLES=OFF
-DWHISPER_OPENVINO=OFF \
%endif
%if %{with openblas}
-DWHISPER_OPENBLAS=ON \
%else
-DWHISPER_OPENBLAS=OFF \
%endif
%if %{with examples}
-DWHISPER_BUILD_EXAMPLES=ON \
%else
-DWHISPER_BUILD_EXAMPLES=OFF \
%endif
%if %{with test}
-DWHISPER_BUILD_TESTS=OFF
-DWHISPER_BUILD_TESTS=ON \
%else
-DWHISPER_BUILD_TESTS=OFF
%endif
%cmake_build
%make_build
%install
%cmake_install
install -Dpm 0644 %{_vpath_srcdir}/main -t %{buildroot}%{_bindir}/whisper.cpp/whisper-cpp
install -Dpm 0644 %{_vpath_srcdir}/quantize -t %{buildroot}%{_bindir}/whisper.cpp/whisper-cpp-quantize
install -Dpm 0644 %{_vpath_srcdir}/server -t %{buildroot}%{_bindir}/whisper.cpp/whisper-cpp-server
install -Dpm 0644 %{_vpath_srcdir}/bench -t %{buildroot}%{_bindir}/whisper.cpp/whisper-cpp-bench
# devel
install -Dp %{_vpath_srcdir}/main -t %{buildroot}%{_libdir}/whisper.cpp/main
install -Dp %{_vpath_srcdir}/quantize -t %{buildroot}%{_libdir}/whisper.cpp/quantize
install -Dp %{_vpath_srcdir}/server -t %{buildroot}%{_libdir}/whisper.cpp/server
install -Dp %{_vpath_srcdir}/bench -t %{buildroot}%{_libdir}/whisper.cpp/bench
install -Dp %{_vpath_srcdir}/ggml-alloc.o -t %{buildroot}%{_libdir}/whisper.cpp/ggml-alloc.o
install -Dp %{_vpath_srcdir}/ggml-backend.o -t %{buildroot}%{_libdir}/whisper.cpp/ggml-backend.o
install -Dp %{_vpath_srcdir}/ggml.o -t %{buildroot}%{_libdir}/whisper.cpp/ggml.o
install -Dp %{_vpath_srcdir}/ggml-quants.o -t %{buildroot}%{_libdir}/whisper.cpp/ggml-quants.o
install -Dp %{_vpath_srcdir}/whisper.o -t %{buildroot}%{_libdir}/whisper.cpp/whisper.o
%check
%ctest
%files
%doc README.md
%doc AUTHORS
%license LICENSE
%{_libdir}/libwhisper.so.%{version}
%{_bindir}/whisper.cpp/whisper-cpp
%{_bindir}/whisper.cpp/whisper-cpp-quantize
%{_bindir}/whisper.cpp/whisper-cpp-server
%{_bindir}/whisper.cpp/whisper-cpp-bench
%files devel
%doc README.md
%{_includedir}/ggml.h
%{_includedir}/whisper.h
%{_libdir}/libwhisper.so
%license LICENSE
%{_libdir}/whisper.cpp/main
%{_libdir}/whisper.cpp/quantize
%{_libdir}/whisper.cpp/server
%{_libdir}/whisper.cpp/bench
%{_libdir}/whisper.cpp/ggml-alloc.o
%{_libdir}/whisper.cpp/ggml-backend.o
%{_libdir}/whisper.cpp/ggml.o
%{_libdir}/whisper.cpp/ggml-quants.o
%{_libdir}/whisper.cpp/whisper.o
%changelog
%autochangelog