{"record":{"id":"5f6a5e53fa14e07e","repo":"cjpais/Handy","slug":"failed-to-create-session-for-whisper-model","errorCode":null,"errorMessage":"Failed to create session for whisper model {}: {}","messagePattern":"Failed to create session for whisper model (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/transcription.rs","lineNumber":586,"sourceCode":"                let model_options = ModelOptions {\n                    backend,\n                    gpu_device,\n                };\n                let model = Model::load_with(&model_path, &model_options).map_err(|e| {\n                    let error_msg = format!(\"Failed to load whisper model {}: {}\", model_id, e);\n                    emit_loading_failed(&error_msg);\n                    anyhow::anyhow!(error_msg)\n                })?;\n                // The bound backend may differ from the request (e.g. CPU\n                // fallback under Auto); log what actually loaded.\n                let bound_backend = model.backend();\n                let session = model.session().map_err(|e| {\n                    let error_msg = format!(\n                        \"Failed to create session for whisper model {}: {}\",\n                        model_id, e\n                    );\n                    emit_loading_failed(&error_msg);\n                    anyhow::anyhow!(error_msg)\n                })?;\n                // Reconcile the registry's advertised capabilities with the\n                // loaded model's real ones (GGUF metadata) so badges/gating\n                // reflect runtime truth, not the pre-download probe. The\n                // load-completed event below triggers the frontend refresh.\n                let caps = session.model().capabilities();\n                self.model_manager.set_runtime_capabilities(\n                    model_id,\n                    caps.supports_streaming,\n                    caps.supports_translate,\n                    caps.supports_language_detect,\n                    caps.languages.clone(),\n                );\n                info!(\n                    \"Loaded whisper model '{}' (requested {:?}, gpu_device {}, bound backend '{}', \\\n                     supports_streaming={}, supports_translate={}, supports_language_detect={})\",\n                    model_id,\n                    backend,","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/cjpais/Handy/blob/98a4d80cce8ad41efec2a419b59d9e81229a35d7/src-tauri/src/managers/transcription.rs#L568-L604","documentation":"The GGUF file loaded, but creating the inference session (model.session()) failed — the backend could not initialize its compute context. Causes sit mostly at the GPU layer: Vulkan/Metal device or context creation failure, VRAM exhaustion at context init, or driver instability. The error is distinct from load failure: the file itself was parsed successfully, and runtime capabilities reconciliation never runs because the session is unavailable.","triggerScenarios":"Vulkan context creation failure (missing or broken drivers, headless session without a GPU); VRAM exhausted by another application; device lost during initialization; CPU backend with insufficient RAM for context buffers.","commonSituations":"Linux systems with incomplete Vulkan stacks; GPUs near VRAM capacity; driver updates mid-session; multi-GPU systems where the selected transcribe_gpu_device index is unavailable.","solutions":["Switch the accelerator to CPU, or select a different gpu_device index, and retry","Ensure the Vulkan runtime is present and healthy (vulkaninfo) and update GPU drivers","Free VRAM: close other GPU-heavy apps or use a smaller model","Check logs for the embedded backend error and report it if it persists on healthy drivers"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Cheap device sanity check before selecting a GPU backend\nfn gpu_backend_likely_ok(accelerator: &Accelerator) -> bool {\n    match accelerator {\n        Accelerator::Cpu => true,\n        Accelerator::Vulkan => vulkan_available(), // e.g. vulkaninfo succeeds\n        Accelerator::Auto => true,                 // auto can fall back internally\n    }\n}","typeGuard":null,"tryCatchPattern":"let session = match model.session() {\n    Ok(s) => s,\n    Err(e) => {\n        // context init failed on the bound GPU backend: rebuild model on CPU\n        drop(model);\n        let cpu_opts = ModelOptions { backend: Backend::Cpu, gpu_device: 0 };\n        let cpu_model = Model::load_with(&model_path, &cpu_opts)?;\n        cpu_model.session().map_err(|e2| anyhow::anyhow!(\n            \"session failed on GPU ({}) and CPU ({})\", e, e2))?  \n    }\n};","preventionTips":["Provide a CPU fallback path for every GPU-backed model load","Validate the Vulkan stack (vulkaninfo) before defaulting to GPU acceleration","Free VRAM before loading large models; prefer smaller quants on marginal GPUs"],"tags":["whisper","session-init","gpu","vulkan","transcribe-cpp"],"backgroundTag":"gpu-context-creation-failed","analyzedSha":"98a4d80cce8ad41efec2a419b59d9e81229a35d7","analyzedAt":"2026-08-16T20:58:09.966Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}