tazz4843/whisper-rs

How to generate ggml-metal.metal?

WenqingZong opened this issue · 2 comments

Hi, I'm trying to run whisper-rs on my MacBook Air, with M2 chip. My cargo.toml file is:

whisper-rs = { version = "0.10.0", features = ["coreml", "metal"] }

And I've downloaded ggml-tiny.bin into my project root. However, when running the code, I get:

whisper_init_from_file_with_params_no_state: loading model from '/Users/wenqingzong/Projects/whisper-rs-test/ggml-tiny.bin'
whisper_model_load: loading model
whisper_model_load: n_vocab       = 51865
whisper_model_load: n_audio_ctx   = 1500
whisper_model_load: n_audio_state = 384
whisper_model_load: n_audio_head  = 6
whisper_model_load: n_audio_layer = 4
whisper_model_load: n_text_ctx    = 448
whisper_model_load: n_text_state  = 384
whisper_model_load: n_text_head   = 6
whisper_model_load: n_text_layer  = 4
whisper_model_load: n_mels        = 80
whisper_model_load: ftype         = 1
whisper_model_load: qntvr         = 0
whisper_model_load: type          = 1 (tiny)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: n_langs       = 99
whisper_backend_init: using Metal backend
ggml_metal_init: allocating
ggml_metal_init: found device: Apple M2
ggml_metal_init: picking default device: Apple M2
ggml_metal_init: default.metallib not found, loading from source
ggml_metal_init: error: could not use bundle path to find ggml-metal.metal, falling back to trying cwd
ggml_metal_init: loading 'ggml-metal.metal'
ggml_metal_init: error: Error Domain=NSCocoaErrorDomain Code=260 "The file “ggml-metal.metal” couldn’t be opened because there is no such file." UserInfo={NSFilePath=ggml-metal.metal, NSUnderlyingError=0x600002b715c0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
[1]    21387 segmentation fault  cargo run

How can I generate the required ggml-metal.metal file?

Thanks in advance!

I haven't touched macOS and have no clue about it, but this file in upstream may be what you need: https://github.com/ggerganov/whisper.cpp/blob/master/ggml-metal.metal
If you get some errors from that one, try checking out the commit used in whisper-rs's submodule instead of master.

thanks, solved