Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whisper.cpp 1.7.1: Crash on Simulator in ggml-metal.m:3283, trying to access MTLDevice #2522

Open
zapsleep opened this issue Oct 29, 2024 · 2 comments

Comments

@zapsleep
Copy link

zapsleep commented Oct 29, 2024

We started having crashes since version 1.7.1 (didn't check 1.7.0 though) when using Whisper.cpp on Simulator or Preview.
It crashes in ggml-metal.m on line 3283:

ctx->buffers[0].metal = [device newBufferWithBytesNoCopy:ctx->all_data
                            length:size_aligned
                            options:MTLResourceStorageModeShared
                            deallocator:nil];

I'm not familiar with Metal too much but it looks like it tries to work with a GPU device while Simulator doesn't have one? Explicitly setting context_parameters.use_gpu = false solves the issue. But it switched to CPU-only automatically on versions prior to 1.7.1 (or 1.7.0).

Tested on iOS 17.5 and 18.x simulator runtimes. Xcode 16.0, macOS 15.0.1.

Stack trace:

Thread 12 Queue : com.apple.root.user-initiated-qos.cooperative (concurrent)
#0	0x00000001800dd63c in _xpc_api_misuse ()
#1	0x00000001800d3cd4 in _xpc_shmem_create_with_prot ()
#2	0x0000000226ef63f8 in -[MTLSimDevice newBufferWithLength:options:pointer:copyBytes:deallocator:] ()
#3	0x00000001c5127c48 in -[MTLDebugDevice newBufferWithBytesNoCopy:length:options:deallocator:] ()
#4	0x000000010424b824 in ggml_backend_metal_buffer_type_alloc_buffer at ggml-metal.m:3283
#5	0x0000000104243b80 in alloc_tensor_range at ggml-alloc.c:940
#6	0x0000000104243ab8 in ggml_backend_alloc_ctx_tensors_from_buft at ggml-alloc.c:1018
#7	0x00000001042d26a0 in whisper_model_load at whisper.cpp:1799
#8	0x00000001042cea54 in ::whisper_init_with_params_no_state(whisper_model_loader *, whisper_context_params) at whisper.cpp:3659
#9	0x00000001042ce7cc in ::whisper_init_from_file_with_params_no_state(const char *, whisper_context_params) at whisper.cpp:3597
#10	0x00000001042d34a4 in ::whisper_init_from_file_with_params(const char *, whisper_context_params) at whisper.cpp:3672
#11	0x00000001038a5508 in <redacted>
#12	0x00000001039e9be4 in <redacted>
#13	0x00000001039f0558 in <redacted>
#14	0x000000010393503c in <redacted>
#15	0x0000000103932ab4 in <redacted>
#16	0x0000000103b12784 in closure #1 in <redacted>
#17	0x0000000103b258f4 in partial apply for closure #1 in <redacted> ()
#18	0x0000000103777b40 in thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) ()
#19	0x0000000103779728 in partial apply for thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) ()
@zapsleep zapsleep changed the title Whisper.cpp 1.7.1: Crash on Simulator in ggml-metal.m:3283, trying to access MTLDevice when there's no GPU Whisper.cpp 1.7.1: Crash on Simulator in ggml-metal.m:3283, trying to access MTLDevice Oct 29, 2024
@ggerganov
Copy link
Owner

Can you check if this works on latest master?

@zapsleep
Copy link
Author

zapsleep commented Nov 1, 2024

Checked on 0377596 (currently latest)
Got the same crash. Stack trace below:

Thread 3 Queue : com.apple.root.user-initiated-qos.cooperative (concurrent)
#0	0x00000001800dd5dc in _xpc_api_misuse ()
#1	0x00000001800d3c74 in _xpc_shmem_create_with_prot ()
#2	0x00000002275c03f8 in -[MTLSimDevice newBufferWithLength:options:pointer:copyBytes:deallocator:] ()
#3	0x00000001c5788af0 in -[MTLDebugDevice newBufferWithBytesNoCopy:length:options:deallocator:] ()
#4	0x00000001062d82e0 in ggml_backend_metal_buffer_type_alloc_buffer at ggml-metal.m:3378
#5	0x00000001062d0580 in alloc_tensor_range at ggml-alloc.c:938
#6	0x00000001062d04b8 in ggml_backend_alloc_ctx_tensors_from_buft at ggml-alloc.c:1016
#7	0x000000010635f56c in whisper_model_load at whisper.cpp:1803
#8	0x000000010635b920 in ::whisper_init_with_params_no_state(whisper_model_loader *, whisper_context_params) at whisper.cpp:3676
#9	0x000000010635b680 in ::whisper_init_from_file_with_params_no_state(const char *, whisper_context_params) at whisper.cpp:3611
#10	0x0000000106360370 in ::whisper_init_from_file_with_params(const char *, whisper_context_params) at whisper.cpp:3689
#11	0x0000000105931f74 in <redacted>
#12	0x0000000105a76650 in <redacted>
#13	0x0000000105a7cfc4 in <redacted>
#14	0x00000001059c1aa8 in <redacted>
#15	0x00000001059bf520 in <redacted>
#16	0x0000000105b9f1f0 in closure #1 in <redacted>
#17	0x0000000105bb2360 in partial apply for closure #1 in <redacted>
#18	0x00000001058045ac in thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) ()
#19	0x0000000105806194 in partial apply for thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) ()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants