{"record":{"id":"0fe75b66f548f525","repo":"screenpipe/screenpipe","slug":"mlx-transcription-panic-likely-metal-gpu-error","errorCode":null,"errorMessage":"mlx transcription panic (likely Metal GPU error): {}","messagePattern":"mlx transcription panic \\(likely Metal GPU error\\): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/screenpipe-audio/src/transcription/engine.rs","lineNumber":852,"sourceCode":"                    }));\n                    mlx_memory::clear_cache();\n                    match outcome {\n                        Ok(Ok(result)) => {\n                            had_success = true;\n                            let text = result.text.trim().to_string();\n                            if !text.is_empty() {\n                                texts.push(text);\n                            }\n                        }\n                        Ok(Err(e)) => last_err = Some(anyhow!(\"{}\", e)),\n                        Err(panic) => {\n                            let msg = panic\n                                .downcast_ref::<String>()\n                                .map(|s| s.as_str())\n                                .or_else(|| panic.downcast_ref::<&str>().copied())\n                                .unwrap_or(\"unknown panic\");\n                            last_err = Some(anyhow!(\n                                \"mlx transcription panic (likely Metal GPU error): {}\",\n                                msg\n                            ));\n                        }\n                    }\n                }\n\n                // Any successful chunk yields a (possibly partial) transcript rather\n                // than discarding the whole batch. Only error if every chunk failed.\n                if had_success {\n                    Ok(texts.join(\" \"))\n                } else {\n                    Err(last_err.unwrap_or_else(|| anyhow!(\"mlx transcription produced no output\")))\n                }\n            }\n\n            Self::Whisper {\n                state,\n                languages,","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/screenpipe/screenpipe/blob/4ebf712990fee17eeaf904dacf749b6e96ac9bf3/crates/screenpipe-audio/src/transcription/engine.rs#L834-L870","documentation":"The MLX (Apple Silicon) transcription engine catches panics from spawned transcription tasks via catch_unwind and records that the model likely crashed due to a Metal GPU error. The `{}` is filled with the panic message; this is raised inside `transcribe` as it retries/falls back (called by `transcribe_detailed`).","triggerScenarios":"Running Whisper-family models via MLX when the Metal device hits an out-of-memory condition, an unsupported operation, or a driver-level assert inside the mlx-rs crate.","commonSituations":"Long audio files exhausting GPU memory; other apps holding Metal resources; older macOS/GPU combos; model too large for available unified memory.","solutions":["Retry with a smaller model (e.g. large -> small/base) to reduce VRAM/unified-memory pressure","Chunk long audio into shorter segments before transcription","Close GPU-heavy apps or reboot to free Metal memory","Update macOS and the mlx crates; fall back to a non-MLX (CPU/ONNX) engine if configured"],"exampleFix":"// before\nlet result = mlx_engine.transcribe(&audio).await?;\n// after\nlet result = match mlx_engine.transcribe(&audio).await {\n    Ok(r) => Ok(r),\n    Err(e) if e.to_string().contains(\"Metal\") => cpu_engine.transcribe(&audio).await,\n    Err(e) => Err(e),\n};","handlingStrategy":"fallback","validationCode":"if audio_samples.len() > MAX_CHUNK { chunk audio before calling transcribe }","typeGuard":null,"tryCatchPattern":"match engine.transcribe(audio).await { Ok(r) => r, Err(e) => fallback_engine.transcribe(audio).await? }","preventionTips":["Use a smaller MLX model when memory is constrained","Chunk long recordings instead of one large transcription","Keep GPU memory headroom; close heavy Metal apps","Pin updated mlx crates and macOS versions"],"tags":["mlx","metal","gpu","transcription","panic"],"backgroundTag":"gpu-out-of-memory","analyzedSha":"4ebf712990fee17eeaf904dacf749b6e96ac9bf3","analyzedAt":"2026-09-01T23:33:43.065Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}