tazz4843 / whisper-rs

Rust bindings to https://github.com/ggerganov/whisper.cpp
The Unlicense
607 stars 105 forks source link

Missing log trampoline #155

Open thewh1teagle opened 4 weeks ago

thewh1teagle commented 4 weeks ago

When using latest whisper-rs with log-trampoline feature some of the logs are still shown in stderr as normal from whisper.cpp

ggml_opencl: selecting platform: 'AMD Accelerated Parallel Processing'
ggml_opencl: selecting device: 'gfx902'
full log ```console target\debug>set RUST_LOG=whisper_rs=debug target\debug>vibe-desktop.exe --model "ggml-medium.bin" --file ..\..\samples\short.wav [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_init_from_file_with_params_no_state: loading model from 'C:\Users\User\AppData\Local\github.com.thewh1teagle.vibe\ggml-medium.bin' [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_init_with_params_no_state: use gpu = 0 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_init_with_params_no_state: flash attn = 0 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_init_with_params_no_state: gpu_device = 0 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_init_with_params_no_state: dtw = 0 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: loading model [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_vocab = 51865 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_audio_ctx = 1500 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_audio_state = 1024 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_audio_head = 16 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_audio_layer = 24 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_text_ctx = 448 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_text_state = 1024 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_text_head = 16 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_text_layer = 24 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_mels = 80 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: ftype = 1 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: qntvr = 0 [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: type = 4 (medium) [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: adding 1608 extra tokens [2024-05-31T21:49:41Z INFO whisper_rs::whisper_sys_log] whisper_model_load: n_langs = 99 ggml_opencl: selecting platform: 'AMD Accelerated Parallel Processing' ggml_opencl: selecting device: 'gfx902' [2024-05-31T21:49:42Z INFO whisper_rs::whisper_sys_log] whisper_model_load: CPU total size = 1533.14 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_model_load: model size = 1533.14 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: kv self size = 150.99 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: kv cross size = 150.99 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: kv pad size = 6.29 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: compute buffer (conv) = 28.68 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: compute buffer (encode) = 594.22 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: compute buffer (cross) = 7.85 MB [2024-05-31T21:49:43Z INFO whisper_rs::whisper_sys_log] whisper_init_state: compute buffer (decode) = 142.09 MB ```

I would love to fix it myself, but I've never played with trampolines ; ) a pointer can help.

hlhr202 commented 3 weeks ago

I think currently there is no such way to trampoline opencl log. whisper.cpp doesn't allow setting a log callback in their code. https://github.com/ggerganov/whisper.cpp/blob/af5833e29819810f2d83228228a9a3077e5ccd93/ggml-opencl.cpp#L1103

as a comparison, the ggml_metal backend allows this https://github.com/ggerganov/whisper.cpp/blob/af5833e29819810f2d83228228a9a3077e5ccd93/ggml-metal.h#L43C15-L43C50