{"record":{"id":"ed6534959a0b0893","repo":"cjpais/Handy","slug":"no-compute-device-with-index-index-see-list-d","errorCode":null,"errorMessage":"No compute device with index {index} (see --list-devices)","messagePattern":"No compute device with index (.+?) \\(see --list-devices\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/transcription.rs","lineNumber":1918,"sourceCode":"            let vram_mb = d.memory_total / (1024 * 1024);\n            format!(\n                \"index={} kind={} name={} vram={}MB\",\n                idx, d.kind, name, vram_mb\n            )\n        })\n        .collect()\n}\n\n/// Resolve a `--list-devices` registry index to the (backend, gpu_device) pair\n/// for a transcribe-cpp model load (the `--device-index` flag). The\n/// backend is set explicitly from the device's kind, so there's no \"index 0 =\n/// auto\" ambiguity. Errors if the index isn't a registered, loadable device.\nfn resolve_device_index(index: usize) -> Result<(Backend, i32)> {\n    let device = transcribe_compute_devices()\n        .into_iter()\n        .find(|d| d.index == Some(index))\n        .ok_or_else(|| {\n            anyhow::anyhow!(\"No compute device with index {index} (see --list-devices)\")\n        })?;\n    let backend = match device.kind.as_str() {\n        \"cpu\" => Backend::Cpu,\n        \"metal\" => Backend::Metal,\n        \"cuda\" => Backend::Cuda,\n        \"vulkan\" => Backend::Vulkan,\n        other => {\n            return Err(anyhow::anyhow!(\n                \"Device index {index} has kind '{other}', which cannot host a model\"\n            ))\n        }\n    };\n    // gpu_device is a registry index used only by GPU backends; CPU ignores it.\n    let gpu_device = if matches!(backend, Backend::Cpu) {\n        0\n    } else {\n        index as i32\n    };","sourceCodeStart":1900,"sourceCodeEnd":1936,"githubUrl":"https://github.com/cjpais/Handy/blob/98a4d80cce8ad41efec2a419b59d9e81229a35d7/src-tauri/src/managers/transcription.rs#L1900-L1936","documentation":"resolve_device_index() maps the --device-index CLI value to a registered transcribe-cpp compute device; this error means no device in the startup registry has that index. The registry is built once by init_transcribe_backend() at app start, so the index you passed is not one this process enumerated — it is out of range, stale from an earlier run, or the registry is empty because backend init failed (only a warning is logged at startup).","triggerScenarios":"Passing --device-index N where transcribe_compute_devices() has no device with index == N: N beyond the device count, an index copied from a previous --list-devices run after drivers/hardware changed, GPU not detected this run (backend init failure or driver issue), or hot-unplugged eGPU between listing and use.","commonSituations":"Scripts/autostart entries hard-coding a device index that shifts after a driver update; running the flag on a different machine; GPU absent or disabled so only CPU (index for cpu only) is registered; --list-devices output from before a reboot.","solutions":["Run the app with --list-devices and use an index printed by THIS run","Remove --device-index to fall back to the persisted accelerator setting (Auto/CPU/GPU) instead of pinning a device","Verify the GPU is detected: check the startup log line 'transcribe-cpp initialized with N compute device(s)' and fix drivers if the GPU is missing","Update scripts to resolve the index dynamically (list devices, then pick) instead of hard-coding it"],"exampleFix":"# before\nhandy --transcribe-file clip.wav --model whisper-small --device-index 3  # may be stale\n\n# after\nhandy --list-devices   # note valid indexes for this run, e.g. index=0 kind=cpu, index=1 kind=vulkan\nhandy --transcribe-file clip.wav --model whisper-small --device-index 1","handlingStrategy":"validation","validationCode":"// Validate --device-index against THIS run's registry before loading\nlet valid: Vec<usize> = transcribe_compute_devices().iter().filter_map(|d| d.index).collect();\nanyhow::ensure!(valid.contains(&index),\n    \"--device-index {index} is not registered this run; valid indexes: {valid:?} (run with --list-devices)\");","typeGuard":"// Narrow the CLI value to a registered device before use\nfn registered_device(index: usize) -> Option<ComputeDevice> {\n    transcribe_compute_devices().into_iter().find(|d| d.index == Some(index))\n}","tryCatchPattern":"match tm.load_model_with_device(&model_id, Some(index)) {\n    Err(e) if e.to_string().contains(\"No compute device with index\") => {\n        eprintln!(\"{}\", describe_compute_devices().join(\"\\n\")); // show valid indexes, then exit\n        std::process::exit(2);\n    }\n    other => other?,\n}","preventionTips":["Always cross-check the index against --list-devices output from the same session","Remember indexes are per-run: drivers, hot-plug, and reboots can renumber devices","In scripts, omit --device-index and use the accelerator setting unless pinning is required","Check the startup log line 'transcribe-cpp initialized with N compute device(s)' to confirm the registry is populated"],"tags":["rust","cli","gpu","device-index","transcribe-cpp","validation"],"backgroundTag":"invalid-device-index","analyzedSha":"98a4d80cce8ad41efec2a419b59d9e81229a35d7","analyzedAt":"2026-08-16T20:58:09.966Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}