whisper.cpp icon indicating copy to clipboard operation
whisper.cpp copied to clipboard

Segmentation Fault when running in Termux on Galaxy S23 Ultra

Open eugr opened this issue 8 months ago • 8 comments

Successfully compiled the latest (as of 5/5/2025) code on Galaxy S23 Ultra running Android 15 in Termux. However, when trying to run, getting Segmentation fault pretty much immediately, no matter which model I'm using.

This is different from "illegal instruction" that was reported (and fixed) here previously, as the configure process correctly uses nosme and nosve compile flags as these instructions are disabled in the phone CPU.

Build configuration:

~/whisper.cpp $ cmake . -B build                      CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- The C compiler identification is Clang 20.1.3
-- The CXX compiler identification is Clang 20.1.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /data/data/com.termux/files/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /data/data/com.termux/files/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /data/data/com.termux/files/usr/bin/git (found version "2.49.0")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF
-- CMAKE_SYSTEM_PROCESSOR: aarch64
-- Including CPU backend
-- Found OpenMP_C: -fopenmp=libomp (found version "5.1")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.1")
-- Found OpenMP: TRUE (found version "5.1")
-- ARM detected
-- Performing Test GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E
-- Performing Test GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E - Failed
-- ARM -mcpu not found, -mcpu=native will be used
-- Performing Test GGML_MACHINE_SUPPORTS_dotprod
-- Performing Test GGML_MACHINE_SUPPORTS_dotprod - Success
-- Performing Test GGML_MACHINE_SUPPORTS_i8mm
-- Performing Test GGML_MACHINE_SUPPORTS_i8mm - Success
-- Performing Test GGML_MACHINE_SUPPORTS_sve
-- Performing Test GGML_MACHINE_SUPPORTS_sve - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_nosve
-- Performing Test GGML_MACHINE_SUPPORTS_nosve - Success
-- Performing Test GGML_MACHINE_SUPPORTS_sme
-- Performing Test GGML_MACHINE_SUPPORTS_sme - Failed
-- Performing Test GGML_MACHINE_SUPPORTS_nosme
-- Performing Test GGML_MACHINE_SUPPORTS_nosme - Success
-- ARM feature DOTPROD enabled
-- ARM feature MATMUL_INT8 enabled
-- ARM feature FMA enabled
-- ARM feature FP16_VECTOR_ARITHMETIC enabled
-- Adding CPU backend variant ggml-cpu: -mcpu=native+dotprod+i8mm+nosve+nosme
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Configuring done (7.8s)
-- Generating done (0.1s)
-- Build files have been written to: /data/data/com.termux/files/home/whisper.cpp/build

Segmentation fault:

whisper_init_from_file_with_params_no_state: loading model from 'models/ggml-tiny.bin'                      
whisper_init_with_params_no_state: use gpu    = 0
whisper_init_with_params_no_state: flash attn = 0
whisper_init_with_params_no_state: gpu_device = 0
whisper_init_with_params_no_state: dtw        = 0
whisper_init_with_params_no_state: devices    = 0
whisper_init_with_params_no_state: backends   = 0
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
Segmentation fault

eugr avatar May 05 '25 18:05 eugr

Same thing happens on Galaxy Tab S10+ running OneUI 7. It has MediaTek processor with SVE enabled.

eugr avatar May 07 '25 15:05 eugr

Same thing happens on Galaxy Tab S10+ running OneUI 7. It has MediaTek processor with SVE enabled.

Same thing on OnePlus 13 (which has a Snapgraon SoC).

./whisper-cli -m $HOME/whisper.cpp/models/ggml-medium.bin -f '/sdcard/Music/Audio Media Converter/Argentina_sMemecoinDisasterIsWorseThanYouthink.mp3'
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
whisper_init_from_file_with_params_no_state: loading model from '/data/data/com.termux/files/home/whisper.cpp/models/ggml-medium.bin'
whisper_init_with_params_no_state: use gpu    = 1
whisper_init_with_params_no_state: flash attn = 0
whisper_init_with_params_no_state: gpu_device = 0
whisper_init_with_params_no_state: dtw        = 0
whisper_init_with_params_no_state: devices    = 0
whisper_init_with_params_no_state: backends   = 0
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: ftype         = 1
whisper_model_load: qntvr         = 0
whisper_model_load: type          = 4 (medium)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: n_langs       = 99
Segmentation fault
~/.../build/bin $

At first i assumed this was a gpu problem but after compiling to use the cpu and i still get this error. And it also looks like anyone is going to fix this anytime soon.

guranu avatar Jun 23 '25 07:06 guranu

At first i assumed this was a gpu problem but after compiling to use the cpu and i still get this error.

I noticed in the logs that the path the the dynamic libraries of the backend does not seem to be found:

ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist

Could you try searching for the shared libraries and see where they are on this system, for example on my system when I build with -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON I see the following files:

$ find build -name *.so
build/bin/libggml-cpu-icelake.so
build/bin/libggml-cpu-sandybridge.so
build/bin/libggml-cpu-x64.so
build/bin/libggml-cpu-alderlake.so
build/bin/libggml-cpu-sapphirerapids.so
build/bin/libggml-cpu-sse42.so
build/bin/libggml-cpu-haswell.so
build/bin/libggml-cpu-skylakex.so
build/src/libwhisper.so
build/ggml/src/libggml-base.so
build/ggml/src/libggml.so

If they are found you could try using the environment variable GGML_BACKEND_PATH with one of the cpu backend .so and see if that works.

If you can modify cli.cpp you can also specify a path using:

ggml_backend_load_all_from_path("build/bin");

But that depends a bit on your use case and also what the actual issue with the paths is.

If the the shared libraries are not there then I think you would get this error. For example, if I set the path parameter of ggml_backend_load_all_from_path so some non existing directory, and run the example I get the following:

$ ./run-cli.sh 
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist
whisper_init_from_file_with_params_no_state: loading model from 'models/ggml-base.bin'
whisper_init_with_params_no_state: use gpu    = 1
whisper_init_with_params_no_state: flash attn = 0
whisper_init_with_params_no_state: gpu_device = 0
whisper_init_with_params_no_state: dtw        = 0
whisper_init_with_params_no_state: devices    = 0
whisper_init_with_params_no_state: backends   = 0
whisper_model_load: loading model
whisper_model_load: n_vocab       = 51865
whisper_model_load: n_audio_ctx   = 1500
whisper_model_load: n_audio_state = 512
whisper_model_load: n_audio_head  = 8
whisper_model_load: n_audio_layer = 6
whisper_model_load: n_text_ctx    = 448
whisper_model_load: n_text_state  = 512
whisper_model_load: n_text_head   = 8
whisper_model_load: n_text_layer  = 6
whisper_model_load: n_mels        = 80
whisper_model_load: ftype         = 1
whisper_model_load: qntvr         = 0
whisper_model_load: type          = 2 (base)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: n_langs       = 99
./run-cli.sh: line 22: 90101 Segmentation fault      (core dumped) ./build/bin/whisper-cli -m models/ggml-base.bin -f samples/jfk.wav --language auto

danbev avatar Jun 23 '25 08:06 danbev

Oddly enough, I am getting this exact same error on NixOS.

jadc avatar Jul 11 '25 23:07 jadc

Same issue in Termux on Redmi Note 10 Pro.

sergeysi779 avatar Jul 21 '25 10:07 sergeysi779

At first i assumed this was a gpu problem but after compiling to use the cpu and i still get this error.

I noticed in the logs that the path the the dynamic libraries of the backend does not seem to be found:

ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist Could you try searching for the shared libraries and see where they are on this system, for example on my system when I build with -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON I see the following files:

$ find build -name *.so build/bin/libggml-cpu-icelake.so build/bin/libggml-cpu-sandybridge.so build/bin/libggml-cpu-x64.so build/bin/libggml-cpu-alderlake.so build/bin/libggml-cpu-sapphirerapids.so build/bin/libggml-cpu-sse42.so build/bin/libggml-cpu-haswell.so build/bin/libggml-cpu-skylakex.so build/src/libwhisper.so build/ggml/src/libggml-base.so build/ggml/src/libggml.so If they are found you could try using the environment variable GGML_BACKEND_PATH with one of the cpu backend .so and see if that works.

If you can modify cli.cpp you can also specify a path using:

ggml_backend_load_all_from_path("build/bin"); But that depends a bit on your use case and also what the actual issue with the paths is.

If the the shared libraries are not there then I think you would get this error. For example, if I set the path parameter of ggml_backend_load_all_from_path so some non existing directory, and run the example I get the following:

$ ./run-cli.sh ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist ggml_backend_load_best: search path does-not-exist/build/bin/ does not exist whisper_init_from_file_with_params_no_state: loading model from 'models/ggml-base.bin' whisper_init_with_params_no_state: use gpu = 1 whisper_init_with_params_no_state: flash attn = 0 whisper_init_with_params_no_state: gpu_device = 0 whisper_init_with_params_no_state: dtw = 0 whisper_init_with_params_no_state: devices = 0 whisper_init_with_params_no_state: backends = 0 whisper_model_load: loading model whisper_model_load: n_vocab = 51865 whisper_model_load: n_audio_ctx = 1500 whisper_model_load: n_audio_state = 512 whisper_model_load: n_audio_head = 8 whisper_model_load: n_audio_layer = 6 whisper_model_load: n_text_ctx = 448 whisper_model_load: n_text_state = 512 whisper_model_load: n_text_head = 8 whisper_model_load: n_text_layer = 6 whisper_model_load: n_mels = 80 whisper_model_load: ftype = 1 whisper_model_load: qntvr = 0 whisper_model_load: type = 2 (base) whisper_model_load: adding 1608 extra tokens whisper_model_load: n_langs = 99 ./run-cli.sh: line 22: 90101 Segmentation fault (core dumped) ./build/bin/whisper-cli -m models/ggml-base.bin -f samples/jfk.wav --language auto

Just checked and they are located at build/ggml/src I tried changing the path in cli.cpp but that didn't help. I still get errors:

Image

./whisper-cli -m /sdcard/audio/ggml-medium.bin -f /sdcard/audio/Argentina_sMemecoinDisasterIsWorsethanYouthink.wav                  ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist                                      ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
whisper_init_from_file_with_params_no_state: loading model from '/sdcard/audio/ggml-medium.bin'
whisper_init_with_params_no_state: use gpu    = 1                          whisper_init_with_params_no_state: flash attn = 1                          whisper_init_with_params_no_state: gpu_device = 0                          whisper_init_with_params_no_state: dtw        = 0
whisper_init_with_params_no_state: devices    = 0
whisper_init_with_params_no_state: backends   = 0                          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: ftype         = 1                                      whisper_model_load: qntvr         = 0
whisper_model_load: type          = 4 (medium)                             whisper_model_load: adding 1608 extra tokens
whisper_model_load: n_langs       = 99                                     Segmentation fault         ./whisper-cli -m /sdcard/audio/ggml-medium.bin -f /sdcard/audio/Argentina_sMemecoinDisasterIsWorsethanYouthink.wav

guranu avatar Oct 22 '25 12:10 guranu

Seems like i won't be getting my answer any time soon.

guranu avatar Nov 03 '25 14:11 guranu

This looks very strange, the error does not match the path you have set :

./whisper-cli -m /sdcard/audio/ggml-medium.bin -f /sdcard/audio/Argentina_sMemecoinDisasterIsWorsethanYouthink.wav
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist
ggml_backend_load_best: search path /data/data/com.termux/files/home/whisper.cpp/build/bin/../lib does not exist

If I try this locally, just setting this to a non-existent directory the error will contain that path, for example:

int main(int argc, char ** argv) {
    ggml_backend_load_all_from_path("doesnotexist");
    ...
}
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist
ggml_backend_load_best: search path doesnotexist does not exist

Can you try a different non-existing path to see if this is actually taking effect (perhaps the whisper-cli executable is not the same as the one being built)?

danbev avatar Nov 04 '25 06:11 danbev