ggerganov / whisper.cpp

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

talk-llama crash during initialization with opencl and NVIDIA GeForce GT 755M #1896

Open petterreinholdtsen opened 8 months ago

petterreinholdtsen commented 8 months ago

When trying to run the talk-llama example code with OpenCL enabled using a NVIDIA GeForce GT 755M, I get the following crash:

% LC_ALL=C ./obj-x86_64-linux-gnu/bin/talk-llama -mw ../nb-large-ggml-model.bin -ml ../dolphin-2.2.1-mistral-7b.Q5_K_M.gguf  -ng -p Petter -ngl 2
whisper_init_from_file_with_params_no_state: loading model from '../nb-large-ggml-model.bin'
whisper_model_load: loading model
whisper_model_load: n_vocab       = 51866
whisper_model_load: n_audio_ctx   = 1500
whisper_model_load: n_audio_state = 1280
whisper_model_load: n_audio_head  = 20
whisper_model_load: n_audio_layer = 32
whisper_model_load: n_text_ctx    = 448
whisper_model_load: n_text_state  = 1280
whisper_model_load: n_text_head   = 20
whisper_model_load: n_text_layer  = 32
whisper_model_load: n_mels        = 128
whisper_model_load: ftype         = 1
whisper_model_load: qntvr         = 0
whisper_model_load: type          = 5 (large v3)
whisper_model_load: adding 1609 extra tokens
whisper_model_load: n_langs       = 100
ggml_opencl: selecting platform: 'NVIDIA CUDA'
ggml_opencl: selecting device: 'NVIDIA GeForce GT 755M'
ggml_opencl: device FP16 support: false
whisper_model_load:      CPU buffer size =  3094.86 MB
whisper_model_load: model size    = 3094.36 MB
whisper_init_state: kv self size  =  220.20 MB
whisper_init_state: kv cross size =  245.76 MB
whisper_init_state: compute buffer (conv)   =   32.42 MB
whisper_init_state: compute buffer (encode) =  212.42 MB
whisper_init_state: compute buffer (cross)  =    9.38 MB
whisper_init_state: compute buffer (decode) =   99.24 MB
llama_model_loader: loaded meta data with 20 key-value pairs and 291 tensors from ../dolphin-2.2.1-mistral-7b.Q5_K_M.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.name str              = ehartford_dolphin-2.2.1-mistral-7b
llama_model_loader: - kv   2:                       llama.context_length u32              = 32768
llama_model_loader: - kv   3:                     llama.embedding_length u32              = 4096
llama_model_loader: - kv   4:                          llama.block_count u32              = 32
llama_model_loader: - kv   5:                  llama.feed_forward_length u32              = 14336
llama_model_loader: - kv   6:                 llama.rope.dimension_count u32              = 128
llama_model_loader: - kv   7:                 llama.attention.head_count u32              = 32
llama_model_loader: - kv   8:              llama.attention.head_count_kv u32              = 8
llama_model_loader: - kv   9:     llama.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  10:                       llama.rope.freq_base f32              = 10000.000000
llama_model_loader: - kv  11:                          general.file_type u32              = 17
llama_model_loader: - kv  12:                       tokenizer.ggml.model str              = llama
llama_model_loader: - kv  13:                      tokenizer.ggml.tokens arr[str,32002]   = ["<unk>", "<s>", "</s>", "<0x00>", "<...
llama_model_loader: - kv  14:                      tokenizer.ggml.scores arr[f32,32002]   = [0.000000, 0.000000, 0.000000, 0.0000...
llama_model_loader: - kv  15:                  tokenizer.ggml.token_type arr[i32,32002]   = [2, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...
llama_model_loader: - kv  16:                tokenizer.ggml.bos_token_id u32              = 1
llama_model_loader: - kv  17:                tokenizer.ggml.eos_token_id u32              = 32000
llama_model_loader: - kv  18:            tokenizer.ggml.padding_token_id u32              = 0
llama_model_loader: - kv  19:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:   65 tensors
llama_model_loader: - type q5_K:  193 tensors
llama_model_loader: - type q6_K:   33 tensors
llm_load_vocab: special tokens definition check successful ( 261/32002 ).
llm_load_print_meta: format           = GGUF V3 (latest)
llm_load_print_meta: arch             = llama
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 32002
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: n_ctx_train      = 32768
llm_load_print_meta: n_embd           = 4096
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 8
llm_load_print_meta: n_layer          = 32
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_gqa            = 4
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-05
llm_load_print_meta: f_clamp_kqv      = 0.0e+00
llm_load_print_meta: f_max_alibi_bias = 0.0e+00
llm_load_print_meta: n_ff             = 14336
llm_load_print_meta: n_expert         = 0
llm_load_print_meta: n_expert_used    = 0
llm_load_print_meta: rope scaling     = linear
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: n_yarn_orig_ctx  = 32768
llm_load_print_meta: rope_finetuned   = unknown
llm_load_print_meta: model type       = 7B
llm_load_print_meta: model ftype      = Q5_K - Medium
llm_load_print_meta: model params     = 7.24 B
llm_load_print_meta: model size       = 4.78 GiB (5.67 BPW) 
llm_load_print_meta: general.name     = ehartford_dolphin-2.2.1-mistral-7b
llm_load_print_meta: BOS token        = 1 '<s>'
llm_load_print_meta: EOS token        = 32000 '<|im_end|>'
llm_load_print_meta: UNK token        = 0 '<unk>'
llm_load_print_meta: PAD token        = 0 '<unk>'
llm_load_print_meta: LF token         = 13 '<0x0A>'
llm_load_tensors: ggml ctx size       =    0.11 MiB
llm_load_tensors: using OpenCL for GPU acceleration
llm_load_tensors: system memory used  = 4893.11 MiB
llm_load_tensors: offloading 0 repeating layers to GPU
llm_load_tensors: offloaded 0/33 layers to GPU
..................................................................................................
llama_new_context_with_model: n_ctx      = 2048
llama_new_context_with_model: freq_base  = 10000.0
llama_new_context_with_model: freq_scale = 1
llama_new_context_with_model: KV self size  =  256.00 MiB, K (f16):  128.00 MiB, V (f16):  128.00 MiB
llama_build_graph: non-view tensors processed: 676/676
llama_new_context_with_model: compute buffer total size = 159.19 MiB

main: processing, 4 threads, lang = en, task = transcribe, timestamps = 0 ...

init: found 1 capture devices:
init:    - Capture device #0: 'Innebygd lyd Analog stereo'
init: attempt to open default capture device ...
init: obtained spec for input device (SDL Id = 2):
init:     - sample rate:       16000
init:     - format:            33056 (required: 33056)
init:     - channels:          1 (required: 1)
init:     - samples per frame: 1024

main : initializing - please wait ...
CLBlast: OpenCL error: clEnqueueNDRangeKernel: -4
GGML_ASSERT: ./ggml-opencl.cpp:1775: false
[New LWP 647684]
[New LWP 647685]
[New LWP 647686]
[New LWP 647687]
[New LWP 647688]
[New LWP 647689]
[New LWP 647690]
[New LWP 647751]
[New LWP 647752]
[New LWP 647754]
[New LWP 647755]
[New LWP 647756]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f4a3aef2b57 in __GI___wait4 (pid=647772, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
30      ../sysdeps/unix/sysv/linux/wait4.c: No such file or directory.
#0  0x00007f4a3aef2b57 in __GI___wait4 (pid=647772, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
30      in ../sysdeps/unix/sysv/linux/wait4.c
#1  0x00007f4a3b578fbb in ggml_print_backtrace () at ./ggml.c:137
137             waitpid(pid, NULL, 0);
#2  0x00007f4a3b5b808f in ggml_cl_mul_mat_q_f32 (src0=0x556a912f9d80, src1=0x7f4a30711b50, dst=0x7f4a30711ce0) at ./ggml-opencl.cpp:1726
1726                        GGML_ASSERT(false);
#3  0x00007f4a3b59e5f2 in ggml_graph_compute_thread (data=data@entry=0x7ffcc7bbbba0) at ./ggml.c:16537
16537                       ggml_compute_forward(&params, node);
#4  0x00007f4a3b5a1a8e in ggml_graph_compute (cgraph=cgraph@entry=0x7f4a3066a030, cplan=cplan@entry=0x7ffcc7bbbcd0) at ./ggml.c:16827
16827       int compute_status = (size_t) ggml_graph_compute_thread(&workers[0]);
#5  0x00007f4a3b5ab1ab in ggml_backend_cpu_graph_compute (backend=<optimized out>, cgraph=0x7f4a3066a030) at ./ggml-backend.c:616
616         ggml_graph_compute(cgraph, &cplan);
#6  0x00007f4a3b5abd8c in ggml_backend_graph_compute (backend=0x556a90f01f90, cgraph=<optimized out>) at ./ggml-backend.c:199
199         if (!backend->iface.graph_compute(backend, cgraph)) {
#7  0x0000556a8ea51a6d in llama_decode_internal (lctx=..., batch=...) at ./examples/talk-llama/llama.cpp:6260
6260        ggml_backend_graph_compute(lctx.backend, gf);
#8  0x0000556a8ea522dd in llama_eval (ctx=0x556a90effca0, tokens=0x556a90f30e10, n_tokens=261, n_past=0) at ./examples/talk-llama/llama.cpp:10101
10101       const int ret = llama_decode_internal(*ctx, llama_batch_get_one(tokens, n_tokens, n_past, 0));
#9  0x0000556a8ea20c77 in main (argc=<optimized out>, argv=<optimized out>) at ./examples/talk-llama/talk-llama.cpp:407
407             return 1;
[Inferior 1 (process 647683) detached]
Avbrutt (SIGABRT) (kjerne lagret i fil)
%

The build was done using cmake -Bobj-x86_64-linux-gnu -S. -DWHISPER_CLBLAST=ON -DWHISPER_SDL2=1 -DCMAKE_BUILD_TYPE=Debug and the models were fetched from https://huggingface.co/NbAiLab/nb-whisper-large/resolve/main/ggml-model.bin and https://huggingface.co/TheBloke/dolphin-2.2.1-mistral-7B-GGUF/resolve/main/dolphin-2.2.1-mistral-7b.Q5_K_M.gguf?download=true .

It is unclear to me how to debug this. Any clues to spare?

tamo commented 8 months ago

CLBlast: OpenCL error: clEnqueueNDRangeKernel: -4

"-4" looks like an "out of memory." https://github.com/KhronosGroup/OpenCL-Headers/blob/59452533d2afa817bc2dc0da4f783097f4cdbcb0/CL/cl.h#L200

It is unclear to me how to debug this. Any clues to spare?

Perhaps you can try smaller models or larger memory.

petterreinholdtsen commented 8 months ago

[Tamotsu Takahashi]

"-4" looks like an "out of memory."

Aha. Perhaps time to rewrite the code to give more useful error messages.

The GPU only got 1 GiB of memory, so OOM sound likely.

Perhaps you can try smaller models or larger memory.

Is there a way to do like the main program, to only offload the part of the processing to the GPU that there is room for? I had to limit it to 4 layers to get 'main' working.

-- Happy hacking Petter Reinholdtsen