tazz4843 / whisper-rs

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

Invalid hardware instruction #117

Open Rinkashikachi opened 5 months ago

Rinkashikachi commented 5 months ago

Hello!

I'm getting "invalid hardware instruction" on my laptop when running the example code: cargo run --example audio_transcription.

But when I just run make in the whisper.cpp folder, then main -m models/ggml-tiny-q5_1.bin -f sample/jfk.wav without errors.

So my initial assumption that the problem was the lack of AVX instructions was wrong.

I tried changing build.rs but don't know how to deal with it.

How can I correctly change build.rs so that the final result of the compilation matches the launch of the make with which everything works?

cargo run output:

    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/examples/audio_transcription`
whisper_init_from_file_with_params_no_state: loading model from './models/ggml-tiny-q5_1.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         = 9
whisper_model_load: qntvr         = 1
whisper_model_load: type          = 1 (tiny)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: n_langs       = 99
zsh: illegal hardware instruction (core dumped)  cargo run --example audio_transcription

lscpu output:

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         36 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
    CPU family:          6
    Model:               58
    Thread(s) per core:  2
    Core(s) per socket:  2
    Socket(s):           1
    Stepping:            9
    CPU(s) scaling MHz:  77%
    CPU max MHz:         3100,0000
    CPU min MHz:         1200,0000
    BogoMIPS:            4990,23
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts a
                         cpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon peb
                         s bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monit
                         or ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadl
                         ine_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp 
                         tpr_shadow flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts 
                         vnmi md_clear flush_l1d
Virtualization features: 
  Virtualization:        VT-x
Caches (sum of all):     
  L1d:                   64 KiB (2 instances)
  L1i:                   64 KiB (2 instances)
  L2:                    512 KiB (2 instances)
  L3:                    3 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-3
Vulnerabilities:         
  Gather data sampling:  Not affected
  Itlb multihit:         KVM: Mitigation: VMX disabled
  L1tf:                  Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
  Mds:                   Mitigation; Clear CPU buffers; SMT vulnerable
  Meltdown:              Mitigation; PTI
  Mmio stale data:       Unknown: No mitigations
  Retbleed:              Not affected
  Spec rstack overflow:  Not affected
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PB
                         RSB-eIBRS Not affected
  Srbds:                 Vulnerable: No microcode
  Tsx async abort:       Not affected

coredump info output:

           PID: 88609 (audio_transcrip)
           UID: 1000 (archuser)
           GID: 1000 (archuser)
        Signal: 4 (ILL)
  Command Line: target/debug/examples/audio_transcription
    Executable: /home/archuser/dev/neural/whisper-rs/target/debug/examples/audio_transcription
 Control Group: /user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/vte-spaw>
          Unit: user@1000.service
     User Unit: vte-spawn-f981b1ed-138a-4196-9cee-394b85ee46b1.scope
         Slice: user-1000.slice
     Owner UID: 1000 (archuser)
       Boot ID: 3886a41920f5474083fa75f5dc85672f
    Machine ID: 81f62c4c3a13459294c861aa7fe0b8f9
       Storage: /var/lib/systemd/coredump/core.audio_transcrip.1000.3886a41920f5474083fa75f5dc85672f.88609.17>
  Size on Disk: 1.8M
       Message: Process 88609 (audio_transcrip) of user 1000 dumped core.

                Stack trace of thread 88609:
                #0  0x0000558a062e97fd n/a (/home/archuser/dev/neural/whisper-rs/target/debug/examples/audio_tran>
                ELF object binary architecture: AMD x86-64

coredump debug output:

(gdb) bt
#0  ggml_gelu_f32 (x=0)
    at /home/archuser/dev/neural/whisper-rs/target/debug/build/whisper-rs-sys-c98bdf987d2301ff/out/whisper.cpp/ggml.c:1405
#1  ggml_init (params=...)
    at /home/archuser/dev/neural/whisper-rs/target/debug/build/whisper-rs-sys-c98bdf987d2301ff/out/whisper.cpp/ggml.c:2231
#2  0x0000558a0630e1e1 in whisper_model_load (loader=loader@entry=0x7ffd27ae4220, wctx=...)
    at /home/archuser/dev/neural/whisper-rs/target/debug/build/whisper-rs-sys-c98bdf987d2301ff/out/whisper.cpp/whisper.cpp:1312
#3  0x0000558a06314be4 in whisper_init_with_params_no_state (loader=loader@entry=0x7ffd27ae4220, 
    params=params@entry=...)
    at /home/archuser/dev/neural/whisper-rs/target/debug/build/whisper-rs-sys-c98bdf987d2301ff/out/whisper.cpp/whisper.cpp:3259
#4  0x0000558a06314e53 in whisper_init_from_file_with_params_no_state (
    path_model=0x558a06927f60 "./models/ggml-tiny-q5_1.bin", params=...)
    at /home/archuser/dev/neural/whisper-rs/target/debug/build/whisper-rs-sys-c98bdf987d2301ff/out/whisper.cpp/whisper.cpp:3207
#5  0x0000558a062d4d3f in whisper_rs::whisper_ctx::WhisperContext::new_with_params (path=..., parameters=...)
    at src/whisper_ctx.rs:33
#6  0x0000558a062cdeb8 in audio_transcription::main () at examples/audio_transcription.rs:12
#7  0x0000558a062cbe9b in core::ops::function::FnOnce::call_once<fn() -> core::result::Result<(), &str>, ()>
    () at /rustc/a57770440f1ebe5b992551d3bcc489ae211908d4/library/core/src/ops/function.rs:250
#8  0x0000558a062d020e in std::sys_common::backtrace::__rust_begin_short_backtrace<fn() -> core::result::Result<(), &str>, core::result::Result<(), &str>> (f=0x558a062cde70 <audio_transcription::main>)
    at /rustc/a57770440f1ebe5b992551d3bcc489ae211908d4/library/std/src/sys_common/backtrace.rs:154
#9  0x0000558a062d0001 in std::rt::lang_start::{closure#0}<core::result::Result<(), &str>> ()
    at /rustc/a57770440f1ebe5b992551d3bcc489ae211908d4/library/std/src/rt.rs:167
#10 0x0000558a063485d7 in core::ops::function::impls::{impl#2}::call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> ()
    at library/core/src/ops/function.rs:284
#11 std::panicking::try::do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::pa--Type <RET> for more, q to quit, c to continue without paging--
nic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panicking.rs:552
#12 std::panicking::try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/std/src/panicking.rs:516
#13 std::panic::catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panic.rs:142
#14 std::rt::lang_start_internal::{closure#2} () at library/std/src/rt.rs:148
#15 std::panicking::try::do_call<std::rt::lang_start_internal::{closure_env#2}, isize> ()
    at library/std/src/panicking.rs:552
#16 std::panicking::try<isize, std::rt::lang_start_internal::{closure_env#2}> ()
    at library/std/src/panicking.rs:516
#17 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> ()
    at library/std/src/panic.rs:142
#18 std::rt::lang_start_internal () at library/std/src/rt.rs:148
#19 0x0000558a062cffda in std::rt::lang_start<core::result::Result<(), &str>> (
    main=0x558a062cde70 <audio_transcription::main>, argc=1, argv=0x7ffd27ae5158, sigpipe=0)
    at /rustc/a57770440f1ebe5b992551d3bcc489ae211908d4/library/std/src/rt.rs:166
#20 0x0000558a062ced5e in main ()
#21 0x00007f80c8933cd0 in ?? () from /usr/lib/libc.so.6
#22 0x00007f80c8933d8a in __libc_start_main () from /usr/lib/libc.so.6
#23 0x0000558a062c4c05 in _start ()