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

Compile successfully, failed to run example. #95

Closed
garyhai opened this issue Oct 27, 2023 · 10 comments
Closed

Compile successfully, failed to run example. #95

garyhai opened this issue Oct 27, 2023 · 10 comments

Comments

@garyhai
Copy link

garyhai commented Oct 27, 2023

Everything is Ok in version 0.8.0.

Current master branch can pass build phase by cargo build.

(master) % cargo build                                       ~/local/whisper-rs
   Compiling whisper-rs-sys v0.7.3 (/Users/gary/local/whisper-rs/sys)
   Compiling whisper-rs v0.9.0-rc.2 (/Users/gary/local/whisper-rs)
    Finished dev [unoptimized + debuginfo] target(s) in 10.74s

But failed to run example audio_transcription with link error. Tested on Apple macOS, both x86 and M1 CPU.

(master) % cargo run --example audio_transcription           ~/local/whisper-rs
   Compiling whisper-rs v0.9.0-rc.2 (/Users/gary/local/whisper-rs)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin:/Users/gary/local/flutter/bin:/Users/gary/.pub-cache/bin:/Users/gary/Library/Python/3.9/bin:/Users/gary/cloud/apps:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/gary/.cargo/bin:/Users/gary/local/rust/release" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/var/folders/zh/6dlsyqcx3wx36n3vry98gv6m0000gn/T/rustcVz4CYM/symbols.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.12vapthbgf4p6r31.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.1fkjbhdu26jok4s0.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.1n35nl5ba92633sy.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.1q6ujwm77q0o42c8.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.264ckhcj295dbbty.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.28rxkcm73dynqhan.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.2czc4tsaoz6du0ye.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.2d4fpibtkf7fbhs0.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.2sutz9d58u5bklzy.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.2zbwp00pj0smn9zc.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.2zrvexoqw1otn6rm.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.33x19ov4rsc2zvky.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.36h307ukp4jiwlb9.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3bn1vfdk1nirkyn6.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3cgtbchv7xvkc56c.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3ckvxb9q6eyd7ogh.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3dj41uidltvngpb2.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3dsuzfxo01klbs6m.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3kp30guba0vkt4ux.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3s3dhseow9j7qep9.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3tgc72q71otsfy4l.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.3xmhtj9m6fzt4jil.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.40us0fmo4jui41ke.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.41chiesavgiu0644.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.44w68vioakpqs6sd.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.47944ypj63c5t45o.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.4o1jfc3e4f0bs5fk.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.4u13z8r668pioj3q.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.4ytz8lukvfxohkr.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.4zvlr59iqd7oxtnj.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.52eo48gitlui3fd.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.57dyjfka5dem1anr.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.5gtywviepcbkui2r.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.5iwrgdmqj98sz31.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.7tlf88y0maxymhe.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.brknudpnm0pe5fj.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.ecoez1kjdc8bhpr.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.fr3yn8gw4w779dz.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.lw1193dsmtyxlzk.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.p9qgi789jhcm7z8.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.t6jd3skdvbr71o0.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.uvzx9s4f4gzrw05.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.uyoq3pabyc09fjq.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.xyrnvzkhas1yxnt.rcgu.o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613.26dsocyyrpa1dwm0.rcgu.o" "-L" "/Users/gary/local/rust/debug/deps" "-L" "/Users/gary/local/rust/debug/build/whisper-rs-sys-c3a24f5f56af9c2f/out/build" "-L" "/Users/gary/local/rust/debug/build/whisper-rs-sys-c3a24f5f56af9c2f/out" "-L" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/gary/local/rust/debug/deps/libwhisper_rs-779838afa9c5de3b.rlib" "/Users/gary/local/rust/debug/deps/libwhisper_rs_sys-733adc5d9a909311.rlib" "/Users/gary/local/rust/debug/deps/libhound-79ee54fb591ddd0f.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-ddfda73b15f9600b.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-eabe75f1776ca242.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-131ae04902e8c815.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-a6ee6c043bffc279.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-36439e0ce6096072.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-9077577b83fc4fd1.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-983fd450352c94e0.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-054b1ccd53d5cf8e.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-5736cf4f651bb669.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-d58d328b1d6ba75e.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-b8c1767249dac0c7.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-09d4b5c092ea9610.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-f7cb43206a2f6d47.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-9d3e0fefc36a1ed6.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-50e16fadc8d2cb6e.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-fff7598d6e185851.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-c75e4d2c0e3ae5d1.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-6359584a409e26e3.rlib" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-9c90a2632a379147.rlib" "-lc++" "-framework" "Accelerate" "-lSystem" "-lc" "-lm" "-L" "/Users/gary/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/gary/local/rust/debug/examples/audio_transcription-1d0d5875d6f30613" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: ld: warning: no platform load command found in '/private/var/folders/zh/6dlsyqcx3wx36n3vry98gv6m0000gn/T/rustcVz4CYM/symbols.o', assuming: macOS
          ld: warning: object file (/Users/gary/local/rust/debug/deps/libwhisper_rs_sys-733adc5d9a909311.rlib[15](ggml.c.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
          ld: warning: object file (/Users/gary/local/rust/debug/deps/libwhisper_rs_sys-733adc5d9a909311.rlib[16](ggml-alloc.c.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
          ld: warning: object file (/Users/gary/local/rust/debug/deps/libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
          ld: warning: object file (/Users/gary/local/rust/debug/deps/libwhisper_rs_sys-733adc5d9a909311.rlib[18](whisper.cpp.o)) was built for newer 'macOS' version (13.6) than being linked (13.0)
          ld: Undefined symbols:
            _MTLCopyAllDevices, referenced from:
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _MTLCreateSystemDefaultDevice, referenced from:
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _OBJC_CLASS_$_MTLComputePassDescriptor, referenced from:
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _OBJC_CLASS_$_NSBundle, referenced from:
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _OBJC_CLASS_$_NSObject, referenced from:
                _OBJC_CLASS_$_GGMLMetalClass in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _OBJC_CLASS_$_NSString, referenced from:
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _OBJC_METACLASS_$_NSObject, referenced from:
                _OBJC_METACLASS_$_GGMLMetalClass in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _OBJC_METACLASS_$_GGMLMetalClass in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            ___CFConstantStringClassReference, referenced from:
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                 in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                ...
            __objc_empty_cache, referenced from:
                _OBJC_METACLASS_$_GGMLMetalClass in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _OBJC_CLASS_$_GGMLMetalClass in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _objc_autoreleasePoolPop, referenced from:
                _ggml_metal_graph_compute in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _objc_autoreleasePoolPush, referenced from:
                _ggml_metal_graph_compute in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _objc_enumerationMutation, referenced from:
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _objc_msgSend, referenced from:
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_add_buffer in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_add_buffer in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_add_buffer in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_add_buffer in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                _ggml_metal_add_buffer in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
                ...
            _objc_opt_class, referenced from:
                _ggml_metal_init in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
            _objc_release, referenced from:
                _ggml_metal_free in libwhisper_rs_sys-733adc5d9a909311.rlib[17](ggml-metal.m.o)
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `whisper-rs` (example "audio_transcription") due to previous error
@tazz4843
Copy link
Owner

Try #91. If it compiles I'll merge to upstream and do another release.

@garyhai
Copy link
Author

garyhai commented Oct 27, 2023

Try #91. If it compiles I'll merge to upstream and do another release.

It works fine for me. Great job!

@codesoda
Copy link
Contributor

@garyhai Did you add the "metal" feature? Was there anything else you had to add to your Cargo.toml or build.rs?

@codesoda
Copy link
Contributor

@tazz4843 This is failing for me with the same error ggml_metal_init: loading '(null)' from the description in #91. Based on the main example from https://github.com/ggerganov/whisper.cpp, That line should look something like this:

whisper_model_load: ... 
whisper_model_load: ... 
whisper_init_state: ...
ggml_metal_init: allocating
ggml_metal_init: found device: Apple M1
ggml_metal_init: picking default device: Apple M1
ggml_metal_init: loading '/Users/username/projects/whisper.cpp/ggml-metal.metal'
ggml_metal_init: loaded kernel_add                            0x14a709390 | th_max = 1024 | th_width =   32
ggml_metal_init: loaded kernel_add_row                        0x14a709f90 | th_max = 1024 | th_width =   32
ggml_metal_init: loaded kernel_mul                            0x14a70a580 | th_max = 1024 | th_width =   32
ggml_metal_init: loaded kernel_mul_row                        0x14a70ab80 | th_max = 1024 | th_width =   32
ggml_metal_init: loaded kernel_scale                          0x14a70b170 | th_max = 1024 | th_width =   32
ggml_metal_init: loaded kernel_silu                           0x14a70b760 | th_max = 1024 | th_width =   32
ggml_metal_init: ...

I did some digging into the build process for whisper.cpp with metal. When I do a clean make on whisper.cpp with an M1, I get this output:

$ make

I whisper.cpp build info:
I UNAME_S:  Darwin
I UNAME_P:  arm
I UNAME_M:  arm64
I CFLAGS:   -I.              -O3 -DNDEBUG -std=c11   -fPIC -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE -pthread -DGGML_USE_ACCELERATE -DGGML_USE_METAL
I CXXFLAGS: -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE -pthread -DGGML_USE_METAL
I LDFLAGS:   -framework Accelerate -framework Foundation -framework Metal -framework MetalKit
I CC:       Apple clang version 14.0.0 (clang-1400.0.29.202)
I CXX:      Apple clang version 14.0.0 (clang-1400.0.29.202)

c++ -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE -pthread -DGGML_USE_METAL examples/main/main.cpp examples/common.cpp examples/common-ggml.cpp ggml.o ggml-alloc.o whisper.o ggml-metal.o -o main  -framework Accelerate -framework Foundation -framework Metal -framework MetalKit
./main -h

usage: ./main [options] file0.wav file1.wav ...

options:
  -h,        --help              [default] show this help message and exit
  -t N,      --threads N         [4      ] number of threads to use during computation
  -p N,      --processors N      [1      ] number of processors to use during computation
  -ot N,     --offset-t N        [0      ] time offset in milliseconds
  -on N,     --offset-n N        [0      ] segment index offset
  -d  N,     --duration N        [0      ] duration of audio to process in milliseconds
  -mc N,     --max-context N     [-1     ] maximum number of text context tokens to store
  -ml N,     --max-len N         [0      ] maximum segment length in characters
  -sow,      --split-on-word     [false  ] split on word rather than on token
  -bo N,     --best-of N         [2      ] number of best candidates to keep
  -bs N,     --beam-size N       [-1     ] beam size for beam search
  -wt N,     --word-thold N      [0.01   ] word timestamp probability threshold
  -et N,     --entropy-thold N   [2.40   ] entropy threshold for decoder fail
  -lpt N,    --logprob-thold N   [-1.00  ] log probability threshold for decoder fail
  -debug,    --debug-mode        [false  ] enable debug mode (eg. dump log_mel)
  -tr,       --translate         [false  ] translate from source language to english
  -di,       --diarize           [false  ] stereo audio diarization
  -tdrz,     --tinydiarize       [false  ] enable tinydiarize (requires a tdrz model)
  -nf,       --no-fallback       [false  ] do not use temperature fallback while decoding
  -otxt,     --output-txt        [false  ] output result in a text file
  -ovtt,     --output-vtt        [false  ] output result in a vtt file
  -osrt,     --output-srt        [false  ] output result in a srt file
  -olrc,     --output-lrc        [false  ] output result in a lrc file
  -owts,     --output-words      [false  ] output script for generating karaoke video
  -fp,       --font-path         [/System/Library/Fonts/Supplemental/Courier New Bold.ttf] path to a monospace font for karaoke video
  -ocsv,     --output-csv        [false  ] output result in a CSV file
  -oj,       --output-json       [false  ] output result in a JSON file
  -of FNAME, --output-file FNAME [       ] output file path (without file extension)
  -ps,       --print-special     [false  ] print special tokens
  -pc,       --print-colors      [false  ] print colors
  -pp,       --print-progress    [false  ] print progress
  -nt,       --no-timestamps     [false  ] do not print timestamps
  -l LANG,   --language LANG     [en     ] spoken language ('auto' for auto-detect)
  -dl,       --detect-language   [false  ] exit after automatically detecting language
             --prompt PROMPT     [       ] initial prompt
  -m FNAME,  --model FNAME       [models/ggml-base.en.bin] model path
  -f FNAME,  --file FNAME        [       ] input WAV file path
  -oved D,   --ov-e-device DNAME [CPU    ] the OpenVINO device used for encode inference
  -ls,       --log-score         [false  ] log best decoder scores of tokens

c++ -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE -pthread -DGGML_USE_METAL examples/bench/bench.cpp ggml.o ggml-alloc.o whisper.o ggml-metal.o -o bench  -framework Accelerate -framework Foundation -framework Metal -framework MetalKit
c++ -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE -pthread -DGGML_USE_METAL examples/quantize/quantize.cpp examples/common.cpp examples/common-ggml.cpp ggml.o ggml-alloc.o whisper.o ggml-metal.o -o quantize  -framework Accelerate -framework Foundation -framework Metal -framework MetalKit

This build process between sys/cpp and rust is a bit out of my depths. Do you think this info will help at all?

@tazz4843
Copy link
Owner

tazz4843 commented Oct 30, 2023

I'm digging through whisper.cpp's CMakeLists.txt and cannot find any discrepancies. I honestly have no idea why this isn't working at all. macOS still supports OpenCL on Intel chips I believe although it's deprecated. That could be a decent alternative for now until someone can figure this out. As for Apple silicon CoreML is about the only alternative I guess.

@garyhai
Copy link
Author

garyhai commented Oct 30, 2023

@garyhai Did you add the "metal" feature? Was there anything else you had to add to your Cargo.toml or build.rs?

In Cargo.toml, add the features. It works fine on my Mac mini with M1. Failed to run on my iMac with Intel CPU.

whisper-rs = { git = "https://github.com/tazz4843/whisper-rs.git", features = ["coreml", "metal"] }

Failure of iMac is because of low level whisper.cpp with bug to support AMD Radeon Pro 570.

ggml_metal_init: allocating
ggml_metal_init: found device: AMD Radeon Pro 570
ggml_metal_init: picking default device: AMD Radeon Pro 570
ggml_metal_init: loading '/Users/gary/local/whisper.cpp/ggml-metal.metal'
...
...
ggml_metal_init: load pipeline error: Error Domain=CompilerError Code=2 "SC compilation failure
There is a call to an undefined label" UserInfo={NSLocalizedDescription=SC compilation failure
There is a call to an undefined label}
whisper_init_state: ggml_metal_init() failed
error: failed to initialize whisper context

@codesoda
Copy link
Contributor

codesoda commented Nov 1, 2023

This is an upstream issue. The fie ggml-metal.metal is required to sit next to the generated binary. whisper.cpp will likely add an ENV variable lookup to determine the location to load metal resources from.

More info can be found at ggerganov/whisper.cpp#1397.

@tazz4843
Copy link
Owner

Closed by #99?

@codesoda
Copy link
Contributor

Yes, closed by #99

@tazz4843
Copy link
Owner

#99 merged and whisper-rs 0.10.0 released with this update, should be fixed now. If not, feel free to reopen.

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

No branches or pull requests

3 participants