Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whisper-cpp: 1.7.2 -> 1.7.4 #382394

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DontEatOreo
Copy link
Member

@DontEatOreo DontEatOreo commented Feb 15, 2025

Breaking changes:

Notes:

  • CoreML is still broken :/
  • I don't currently have a Linux machine, so I would appreciate someone to test
    the Linux side

Things done:

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@hughobrien
Copy link
Contributor

hughobrien commented Feb 16, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 382394


x86_64-linux

❌ 2 packages failed to build:
  • whisper-cpp
  • whisper-cpp-vulkan
FAILED: bin/whisper-bench 
: && /nix/store/4ijy8jbsiqmj37avrk83gn2m903486mr-gcc-wrapper-14-20241116/bin/g++ -O3 -DNDEBUG -Wl,--dependency-file=examples/bench/CMakeFiles/whisper-bench.dir/>
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_get_f32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_vsx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_arm_fma'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx2'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_compute_with_ctx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_f16c'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_set_f32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_wasm_simd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_set_f32'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_set_i32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_ssse3'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_neon'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_fp16_va'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_get_i32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_sse3'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_backend_cpu_init'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_plan'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_compute'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx512'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_fma'

This feels like more fuss with the cpu feature detection fighting nix's reporoducibility guarantees

@hughobrien
Copy link
Contributor

hughobrien commented Feb 16, 2025

try removing

      (cmakeBool "WHISPER_BUILD_EXAMPLES" true)

I bisected the issue to ggerganov/whisper.cpp@746bf25 but that commit is Tolstoy-esque.

@DontEatOreo
Copy link
Member Author

On Darwin seems to be working, so I will only remove it for Linux

@hughobrien
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 382394


x86_64-linux

❌ 2 packages failed to build:
  • whisper-cpp
  • whisper-cpp-vulkan

@hughobrien
Copy link
Contributor

hughobrien commented Feb 16, 2025

It seems to default to true. I forced it off like this

    ++ optionals (effectiveStdenv.hostPlatform.isx86 && !effectiveStdenv.hostPlatform.isStatic) [
      (cmakeBool "GGML_BACKEND_DL" true)
      (cmakeBool "GGML_CPU_ALL_VARIANTS" true)
      (cmakeBool "WHISPER_BUILD_EXAMPLES" false)
    ]

But then we run afoul of assumptions about the quantize command

mv: cannot stat '/nix/store/r8fv62nkdvqilbxl18gr71haraqdhwis-whisper-cpp-1.7.4/bin/quantize': No such file or directory

I think this is moot anyway since the cli command is also an 'example'.

I've spent a silly amount of time trying to track down this issue, and my best understanding is that Nix is invoking gcc in a way that is confusing the complex logic in https://github.com/ggml-org/ggml/blob/master/src/ggml-cpu/CMakeLists.txt

FAILED: bin/whisper-cli 
: && /nix/store/4ijy8jbsiqmj37avrk83gn2m903486mr-gcc-wrapper-14-20241116/bin/g++ -O3 -DNDEBUG -Wl,--dependency-file=examples/cli/CMakeFiles/whisper-cli.dir/link.d examples/cli/CMakeFiles/whisper-cli.dir/cli.cpp.o -o bin/whisper-cli  -Wl,-rpath,/build/source/build/src:/build/source/build/ggml/src:  examples/libcommon.a  src/libwhisper.so.1.7.4  ggml/src/libggml.so  ggml/src/libggml-base.so && :
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_get_f32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_vsx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_arm_fma'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx2'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_compute_with_ctx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_f16c'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_set_f32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_wasm_simd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_set_f32'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_set_i32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_ssse3'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_neon'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_fp16_va'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_get_i32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_sse3'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_backend_cpu_init'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_plan'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_compute'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx512'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_fma'
collect2: error: ld returned 1 exit status

/data/whisper.cpp/build/src master
shell ❯ nm -D  libwhisper.so.1.7.4 | grep ggml_cp 
                 U ggml_cpu_has_arm_fma
                 U ggml_cpu_has_avx
                 U ggml_cpu_has_avx2
                 U ggml_cpu_has_avx512
                 U ggml_cpu_has_f16c
                 U ggml_cpu_has_fma
                 U ggml_cpu_has_fp16_va
                 U ggml_cpu_has_neon
                 U ggml_cpu_has_sse3
                 U ggml_cpu_has_ssse3
                 U ggml_cpu_has_vsx
                 U ggml_cpu_has_wasm_simd
                 U ggml_cpy
/data/whisper.cpp/build/ggml/src master
shell ❯ nm -D  libggml.so libggml-base.so | grep ggml_cp 
0000000000017550 T ggml_cpy

ggml builds, but doesn't seem to expose the symbols required. Within ggml they're simple functions like

int ggml_cpu_has_ssse3(void) {
#if defined(__SSSE3__)
    return 1;
#else
    return 0;
#endif
}

Which I would expect to be exported, and can only conclude that the CMake complexity is somehow preventing that.

Perhaps @aviallon might have some more knowledge.

@aviallon
Copy link
Contributor

@hughobrien yes, I did try to upgrade to 1.7.4
The issue seems to becaused by the dynamically loaded backends not being built properly.
I haven't found out why exactly, but they do not build.
Removing dynamic backend loading fixes the issue, but makes whisper enormously slower.

@@ -126,6 +123,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
(cmakeBool "GGML_NATIVE" false)
(cmakeBool "BUILD_SHARED_LIBS" (!effectiveStdenv.hostPlatform.isStatic))
]
++ optional effectiveStdenv.hostPlatform.isDarwin (cmakeBool "WHISPER_BUILD_EXAMPLES" true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
++ optional effectiveStdenv.hostPlatform.isDarwin (cmakeBool "WHISPER_BUILD_EXAMPLES" true)
++ [ (cmakeBool "WHISPER_BUILD_EXAMPLES" effectiveStdenv.hostPlatform.isDarwin) ]

@hughobrien
Copy link
Contributor

If we build without the examples then unfortunately we don't get the core utility. However we do get a couple of pre-defined CPU libraries (presumably for dynamic backend selection).

The missing exports are present in these

/data/whisper.cpp/build/bin master
❯ ll                          
.rwxr-xr-x 386k hugh 18 Feb 20:12 libggml-cpu-alderlake.so
.rwxr-xr-x 386k hugh 18 Feb 20:12 libggml-cpu-haswell.so
.rwxr-xr-x 407k hugh 18 Feb 20:12 libggml-cpu-icelake.so
.rwxr-xr-x 398k hugh 18 Feb 20:12 libggml-cpu-sandybridge.so
.rwxr-xr-x 657k hugh 18 Feb 20:12 libggml-cpu-sapphirerapids.so
.rwxr-xr-x 407k hugh 18 Feb 20:12 libggml-cpu-skylakex.so

Note no useful CLI utils.

/data/whisper.cpp/build/bin master
❯ nm -D  libggml-cpu-sapphirerapids.so | grep ggml_cp
000000000004f8b0 T ggml_cpu_extra_compute_forward
000000000004f930 T ggml_cpu_extra_work_size
00000000000311e0 T ggml_cpu_get_sve_cnt
00000000000310f0 T ggml_cpu_has_amx_int8
0000000000031110 T ggml_cpu_has_arm_fma
0000000000031080 T ggml_cpu_has_avx
00000000000310a0 T ggml_cpu_has_avx2
00000000000310b0 T ggml_cpu_has_avx512
00000000000310e0 T ggml_cpu_has_avx512_bf16
00000000000310c0 T ggml_cpu_has_avx512_vbmi
00000000000310d0 T ggml_cpu_has_avx512_vnni
0000000000031090 T ggml_cpu_has_avx_vnni
00000000000311b0 T ggml_cpu_has_dotprod
0000000000031130 T ggml_cpu_has_f16c
0000000000031100 T ggml_cpu_has_fma
0000000000031140 T ggml_cpu_has_fp16_va
0000000000031160 T ggml_cpu_has_llamafile
00000000000311d0 T ggml_cpu_has_matmul_int8
00000000000311a0 T ggml_cpu_has_neon
0000000000031120 T ggml_cpu_has_riscv_v
0000000000031170 T ggml_cpu_has_sse3
0000000000031180 T ggml_cpu_has_ssse3
00000000000311c0 T ggml_cpu_has_sve
0000000000031190 T ggml_cpu_has_vsx
0000000000031150 T ggml_cpu_has_wasm_simd
00000000000313b0 T ggml_cpu_init

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

Successfully merging this pull request may close these issues.

4 participants