Skip to content

[whisper_cpp] Update to v1.9.3; add CUDA (x86_64, aarch64/Jetson) and Metal builds - #14509

Open
ChrisRackauckas wants to merge 1 commit into
JuliaPackaging:masterfrom
ChrisRackauckas:whisper_cpp-1.9.3
Open

[whisper_cpp] Update to v1.9.3; add CUDA (x86_64, aarch64/Jetson) and Metal builds#14509
ChrisRackauckas wants to merge 1 commit into
JuliaPackaging:masterfrom
ChrisRackauckas:whisper_cpp-1.9.3

Conversation

@ChrisRackauckas

Copy link
Copy Markdown
Contributor

Updates whisper_cpp from v1.2.0 (February 2023) to v1.9.3, and adds CUDA (x86_64 and aarch64 Linux) and Metal (Apple Silicon) builds.

Motivation: Whisper.jl is being brought up to date (aviks/Whisper.jl#13) and needs a current library; the 1.2 JLL is three years and ~7 minor releases behind whisper.cpp, and has no GPU backend at all.

What the recipe does

Layout follows L/llama_cpp (same ggml core, maintained here): libwhisper now links the split ggml libraries, all shipped as products — libwhisper, libggml, libggml-base, libggml-cpu, plus libparakeet (new in 1.9) and the whisper-cli / whisper-bench / whisper-quantize executables. The old install_includes.patch is dropped; headers are installed upstream now.

CPU builds (12): supported_platforms() minus armv6l/armv7l/powerpc64le/aarch64-musl (same exclusions as the old recipe and as llama_cpp), expand_cxxstring_abis. -DGGML_NATIVE=OFF; AVX/AVX2/FMA/F16C on x86_64 and i686, as llama_cpp does. Metal on aarch64-apple-darwin with the embedded shader library (compiled at run time, so no Metal toolchain is needed at build time).

CUDA builds (11): through platforms/cuda.jl, one build_tarballs call per platform with CUDA.required_dependencies and augment_platform_block = CUDA.augment, modelled on N/NCCL and M/MAGMA (including the host-nvcc copy for the aarch64 cross-compile, and libnvvm as a separate redist from CUDA 13). CPU artifacts carry no cuda tag, so they remain the fallback on hosts without CUDA_Runtime_jll.

CUDA versions are built at feature boundaries rather than for every minor, since an artifact built against X.Y is selected for any host X.Z ≥ Y and the newest compatible one wins:

CUDA why platforms
12.2 JetPack 6.0 (Jetson Orin); oldest 12.x supported x86_64, jetson, sbsa
12.6 JetPack 6.1 / 6.2 x86_64, jetson, sbsa
12.8 Blackwell (sm_120) support in ggml x86_64, jetson, sbsa
13.0 CUDA 13 / JetPack 7 (no jetson/sbsa split) x86_64, aarch64

CMAKE_CUDA_ARCHITECTURES is left to ggml, which picks a portable list per toolkit version (PTX for older archs, SASS for common ones). Happy to trim the version list if 11 CUDA builds is too much CI.

Two things specific to building ggml-cuda against CUDA_SDK_jll: the SDK keeps libraries in cuda/lib while nvcc's nvcc.profile and FindCUDAToolkit look in lib64 first, and it ships only the shared cudart (libcudart.so, libcudadevrt.a, no libcudart_static.a, which nvcc links by default). The recipe symlinks lib64 -> lib and passes -cudart=shared / CMAKE_CUDA_RUNTIME_LIBRARY=Shared. The shared runtime is what we want anyway — CUDA_Runtime_jll provides libcudart/libcublas at run time. GGML_CUDA_NCCL=OFF (optional, not available here).

Verified locally (BinaryBuilder on macOS via Docker/Rosetta)

  • x86_64-linux-gnu-cxx11 CPU: builds and passes the audit. The only note is the expected "Minimum instruction set detected for libggml-cpu.so is avx2", same as llama_cpp. The resulting tarball was installed on an x86_64 Linux host through Overrides.toml and drives Whisper.jl correctly (transcription and timestamps right; BB's $ORIGIN rpaths resolve the ggml libraries).
  • x86_64-linux-gnu-cxx11-cuda+12.2: cmake configure and CUDA compiler detection pass with the fixes above and the nvcc build is running (203 steps, slow under Rosetta); I will report the outcome here. CI is the real check.
  • aarch64 CUDA cross-builds and the remaining platforms: not built locally (that is hours of nvcc under Rosetta); relying on CI here, as with the other CUDA recipes.

The matching whisper.cpp 1.9.3 binaries built outside BinaryBuilder were exercised on aarch64-linux (Jetson AGX Orin, CPU and CUDA), aarch64-apple-darwin (Metal) and x86_64-linux through Whisper.jl's test suite, so the library itself and its layout are known good on those platforms; what CI validates is the BinaryBuilder cross-compilation of them.

Notes

  • julia_compat = "1.10" (augmented platforms), preferred_gcc_version = v"10" (C++17; CUDA 12/13 host-compiler compatible).
  • WHISPER_BUILD_SERVER=OFF, WHISPER_SDL2=OFF, WHISPER_CURL=OFF: the server and the SDL2 examples pull in extra dependencies and are not needed for the JLL.
  • -DWHISPER_BUILD_IS_DEV=OFF so whisper_version() reports 1.9.3 rather than 1.9.3-dev.

@ChrisRackauckas

Copy link
Copy Markdown
Contributor Author

Local BinaryBuilder result for x86_64-linux-gnu-cxx11-cuda+12.2 (macOS host, Rosetta): all 203 compile steps succeed, including every nvcc kernel, and libwhisper/libggml-cuda link. It failed at the final link of the example executables:

ld: bin/libggml-cuda.so.0.20.2: undefined reference to `cudaMemcpyAsync@libcudart.so.12'
ld: bin/libggml-cuda.so.0.20.2: undefined reference to `cuMemMap'

i.e. ld could not resolve libggml-cuda's own DT_NEEDED libraries while linking whisper-cli & co., since with CMAKE_SKIP_RPATH=ON nothing points it at the SDK. Pushed a fix: -Wl,-rpath-link,${CUDA_HOME}/lib -Wl,-rpath-link,${CUDA_HOME}/lib/stubs in CMAKE_EXE_LINKER_FLAGS for CUDA builds. Re-running locally; will report.

- whisper.cpp v1.9.3 (was v1.2.0 from 2023). Ships the split ggml libraries
  (libggml, libggml-base, libggml-cpu) alongside libwhisper, plus libparakeet
  and the whisper-cli / whisper-bench / whisper-quantize executables.
- Drops the bundled install_includes.patch: headers are installed upstream now.
- Metal on aarch64-apple-darwin (embedded shader library).
- CUDA artifacts for x86_64-linux-gnu and aarch64-linux-gnu (jetson, sbsa, and
  13.x), selected through the cuda platform tag; built at feature boundaries
  (12.2, 12.6, 12.8, 13.0) since the newest compatible artifact is selected.
- Mirrors L/llama_cpp for the CPU build flags and platform exclusions, and
  N/NCCL / M/MAGMA for the aarch64 CUDA cross-compile.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014mQ1kBsPfYwGCQcG8wpVbr
@ChrisRackauckas

Copy link
Copy Markdown
Contributor Author

Second local run: cudart/cublas now resolve; the executables' link still failed on the driver API — ld: warning: libcuda.so.1, needed by bin/libggml-cuda.so.0.20.2, not found — because the SDK's lib/stubs only contains libcuda.so, not the libcuda.so.1 soname that libggml-cuda records. Pushed a one-line fix (symlink libcuda.so.1 -> libcuda.so in the stubs dir, used only via -rpath-link at link time; the runtime dependency stays on the driver's libcuda.so.1). Re-running.

@ChrisRackauckas

Copy link
Copy Markdown
Contributor Author

Local BinaryBuilder build of x86_64-linux-gnu-cxx11-cuda+12.2 (macOS host under Rosetta) now completes and passes the audit with the two linker fixes above (-rpath-link to the SDK lib dirs, libcuda.so.1 soname stub). Tree hash 7f28feb0524e06c24fe9cf81ebbcfbcfe5736e28.

Audit notes:

  • lib/libggml-cuda.so.0.20.2: Linked library libcublas.so.12 could not be resolved and could not be auto-mapped
  • lib/libggml-cuda.so.0.20.2: Linked library libcuda.so.1 could not be resolved and could not be auto-mapped
  • lib/libggml-cuda.so.0.20.2: Linked library libcudart.so.12 could not be resolved and could not be auto-mapped
  • Minimum instruction set detected for lib/libggml-cpu.so.0.20.2 is avx2, not x86_64 as desired.

(Posted automatically when the local build finished.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant