ggerganov / whisper.cpp

Port of OpenAI's Whisper model in C/C++
MIT License
35.72k stars 3.64k forks source link

Get SIGILL on Intel(R) Core(TM) i5-2520M (Thinkpad X220) #828

Open petterreinholdtsen opened 1 year ago

petterreinholdtsen commented 1 year ago

I tried running whisper.cpp on a Thinkpad X220 today, and the program crash with SIGILL.

Is there some inline assembly assuming a newer CPU?

% gdb bin/main
[...]
(gdb) run -m model-medium/ggml-model.bin ~/stemmetest-oda-2023-04-16.wav
Starting program: /home/user/whisper.cpp/build/bin/main -m model-medium/ggml-model.bin ~/stemmetest-oda-2023-04-16.wav
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
whisper_init_from_file_no_state: loading model from 'model-medium/ggml-model.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 = 1024
whisper_model_load: n_audio_head  = 16
whisper_model_load: n_audio_layer = 24
whisper_model_load: n_text_ctx    = 448
whisper_model_load: n_text_state  = 1024
whisper_model_load: n_text_head   = 16
whisper_model_load: n_text_layer  = 24
whisper_model_load: n_mels        = 80
whisper_model_load: f16           = 1
whisper_model_load: type          = 4
whisper_model_load: mem required  = 1725.00 MB (+   43.00 MB per decoder)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: model ctx     = 1462.35 MB

Program received signal SIGILL, Illegal instruction.
0x00007ffff7ec6d3a in ggml_init () from /home/user/whisper.cpp/build/libwhisper.so
(gdb) x/i $pc
=> 0x7ffff7ec6d3a <ggml_init+362>:      vcvtph2ps %xmm1,%xmm1
(gdb)
petterreinholdtsen commented 1 year ago

I adjusted the build to include debug symbols in the binary, and got this backtrace:

Program received signal SIGILL, Illegal instruction.
b0x00007ffff7cc8b9b in _cvtsh_ss (__S=0)
    at /usr/lib/gcc/x86_64-linux-gnu/12/include/f16cintrin.h:41
41        __v4sf __A = __builtin_ia32_vcvtph2ps (__H);
(gdb) bt
#0  0x00007ffff7cc8b9b in _cvtsh_ss (__S=0)
    at /usr/lib/gcc/x86_64-linux-gnu/12/include/f16cintrin.h:41
#1  ggml_init (params=...) at /home/user/whisper.cpp/ggml.c:3020
#2  0x00007ffff7ce2fa6 in whisper_model_load (loader=0x7fffffffdf60, wctx=...)
    at /home/user/whisper.cpp/whisper.cpp:1050
#3  0x00007ffff7cebd44 in whisper_init_no_state (loader=0x7fffffffdf60)
    at /home/user/whisper.cpp/whisper.cpp:2683
#4  0x00007ffff7ceba7f in whisper_init_from_file_no_state (
    path_model=0x55555562edc0 "model-medium/ggml-model.bin")
    at /home/user/whisper.cpp/whisper.cpp:2633
#5  0x00007ffff7cebde2 in whisper_init_from_file (
    path_model=0x55555562edc0 "model-medium/ggml-model.bin")
    at /home/user/whisper.cpp/whisper.cpp:2696
#6  0x00005555555baec9 in main (argc=4, argv=0x7fffffffe3b8)
    at /home/user/whisper.cpp/examples/main/main.cpp:706
(gdb)
petterreinholdtsen commented 1 year ago

I've been told https://wiki.debian.org/InstructionSelection contain some ideas how to fix this.

papperlapapp commented 1 year ago

Incidentally, I got the exact same error on an Intel(R) Core(TM) i7-3770 (using gcc 12.2.1).

However, after running make clean and make again, the error vanished. So maybe some leftovers from previous compiles?

petterreinholdtsen commented 1 year ago

[papperlapapp]

However, after running make clean and make again, the error vanished. So maybe some leftovers from previous compiles?

I on the other hand could get a bit further by using 'cmake -DWHISPER_NO_F16C=1', to try to disable the code that crash. Sadly I ran into another segfault I have not had time to debug yet.

-- Happy hacking Petter Reinholdtsen