~ruther/guix-local

a707ebe5d3875a49523bc17de2d36af6f1c18f7e — Andy Tai 1 year, 4 months ago 5d7455b
gnu: whisper-cpp: Enable sdl2 and tests.

* gnu/packages/patches/whisper-cpp-enable-tests.patch: New file.
* gnu/packages/machine-learning.scm (whisper-cpp)[source]: Add reference to
patch.
[arguments]<#:configure-flags>: Add configure flags.
[arguments]<#:phases>: Disable big test on 32 bit.
[inputs]: Add sdl2.
[synopsis]: Modify.
[description]: Modify.
* gnu/local.mk (dist_PATCH_DATA): Register patch.

Signed-off-by: Danny Milosavljevic <dannym@friendly-machines.com>
Change-Id: Icdb82c3c7d3d485346f89fe699d0d64b34c1b21a
Signed-off-by: Danny Milosavljevic <dannym@friendly-machines.com>
M gnu/local.mk => gnu/local.mk +1 -0
@@ 2377,6 2377,7 @@ dist_patch_DATA =						\
  %D%/packages/patches/webrtc-audio-processing-x86-no-sse.patch	\
  %D%/packages/patches/webrtc-for-telegram-desktop-unbundle-libsrtp.patch \
  %D%/packages/patches/websocketpp-fix-for-cmake-3.15.patch	\
  %D%/packages/patches/whisper-cpp-enable-tests.patch           \
  %D%/packages/patches/wmctrl-64-fix.patch			\
  %D%/packages/patches/wmfire-dont-inline-draw-fire.patch	\
  %D%/packages/patches/wmfire-update-for-new-gdk-versions.patch	\

M gnu/packages/machine-learning.scm => gnu/packages/machine-learning.scm +57 -25
@@ 118,6 118,7 @@
  #:use-module (gnu packages rdf)
  #:use-module (gnu packages regex)
  #:use-module (gnu packages rpc)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages serialization)
  #:use-module (gnu packages sphinx)
  #:use-module (gnu packages statistics)


@@ 677,39 678,70 @@ independently to be able to run a LLaMA model.")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/ggerganov/whisper.cpp")
                     (commit (string-append "v" version))))
                    (url "https://github.com/ggerganov/whisper.cpp")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0rrkgrx8akw91b77kl36i03i39a79r0p69glhhidm28qfw02icjx"))))
                "0rrkgrx8akw91b77kl36i03i39a79r0p69glhhidm28qfw02icjx"))
              (patches (search-patches "whisper-cpp-enable-tests.patch"))))
    (build-system cmake-build-system)
    (arguments
      (list
        #:tests? #false ; uhh. They have it commented out in CMakeLists.txt
        #:configure-flags
        #~(list "-DBUILD_SHARED_LIBS=ON"
                "-DGGML_BLAS=ON"
                "-DGGML_BLAS_VENDOR=OpenBLAS"
                (string-append "-DBLAS_INCLUDE_DIRS="
                               #$(this-package-input "openblas")
                               "/include")
                (string-append "-DBLAS_LIBRARIES="
                               #$(this-package-input "openblas")
                               "/lib/libopenblas.so")

                "-DGGML_NATIVE=OFF" ;no '-march=native'
                "-DGGML_FMA=OFF"    ;and no '-mfma', etc.
                "-DGGML_AVX2=OFF"
                "-DGGML_AVX512=OFF"
                "-DGGML_AVX512_VBMI=OFF"
                "-DGGML_AVX512_VNNI=OFF")))
     (list
      #:tests? #false ; uhh. They have it commented out in CMakeLists.txt
      #:configure-flags
      #~(list "-DWHISPER_STANDALONE=TRUE"
              "-DWHISPER_SDL2=TRUE"
              "-DWHISPER_BUILD_TESTS=TRUE"
                                        ; "-DWHISPER_FFMPEG=TRUE"  ; TODO
              "-DBUILD_SHARED_LIBS=ON"
              "-DGGML_BLAS=ON"
              "-DGGML_BLAS_VENDOR=OpenBLAS"
              (string-append "-DBLAS_INCLUDE_DIRS="
                             #$(this-package-input "openblas")
                             "/include")
              (string-append "-DBLAS_LIBRARIES="
                             #$(this-package-input "openblas")
                             "/lib/libopenblas.so")

              "-DGGML_NATIVE=OFF" ;no '-march=native'
              "-DGGML_FMA=OFF"    ;and no '-mfma', etc.
              "-DGGML_AVX2=OFF"
              "-DGGML_AVX512=OFF"
              "-DGGML_AVX512_VBMI=OFF"
              "-DGGML_AVX512_VNNI=OFF")
      #:phases
      #~(modify-phases %standard-phases
          #$@(if (not (target-64bit?))
                 '((add-after 'unpack 'skip-failing-tests
                     (lambda _
                       ;; 32-bit system
                       ;; large model does not fit in RAM in 32-bit system,
                       ;; disable large model test
                       (substitute* "tests/CMakeLists.txt"
                         (("LABELS \"large\"")
                          "DISABLED true")))))
                 '()))))
    (native-inputs
     (list pkg-config))
    (inputs
     (list openblas))
    (synopsis "Speech recognition")
    (description "This package provides speech recognition.")
     (list openblas sdl2))
    (synopsis "OpenAI's Whisper model in C/C++")
    (description
     "This package is a high-performance inference of OpenAI's
Whisper automatic speech recognition (ASR) model, implemented in plain C/C++
without dependencies, with
@itemize
@item AVX intrinsics support for x86 architectures
@item VSX intrinsics support for POWER architectures
@item Mixed F16 / F32 precision
@item 4-bit and 5-bit integer quantization support
@item Zero memory allocations at runtime
@item Support for CPU-only inference
@item Efficient GPU support for NVIDIA
@item OpenVINO Support
@item C-style API
@end itemize")
    (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available
    (home-page "https://github.com/ggerganov/whisper.cpp")
    (license license:expat)))

A gnu/packages/patches/whisper-cpp-enable-tests.patch => gnu/packages/patches/whisper-cpp-enable-tests.patch +19 -0
@@ 0,0 1,19 @@
Distribution specific patch

restored tests commented out in CMakeLists.txt upstream

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c53252b..ee06015 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,8 +176,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/whisper.pc"
 #

 if (WHISPER_BUILD_TESTS AND NOT CMAKE_JS_VERSION)
-    #include(CTest)
-    #add_subdirectory(tests)
+    include(CTest)
+    add_subdirectory(tests)
 endif ()

 if (WHISPER_BUILD_EXAMPLES)