{"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":1944,"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 an exact opaque device handle\n/// for a transcribe-cpp model load (the `--device-index` flag). In 0.2 index 0\n/// is an exact selection too; only an omitted index requests automatic device\n/// selection. Errors if the index isn't a registered, loadable primary device.\nfn resolve_device_index(index: usize) -> Result<(Backend, Option<transcribe_cpp::Device>)> {\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    if matches!(\n        device.device_type,\n        transcribe_cpp::DeviceType::Accel | transcribe_cpp::DeviceType::Unknown\n    ) {\n        return Err(anyhow::anyhow!(\n            \"Device index {index} ({}) cannot host a model\",\n            device.kind\n        ));\n    }\n\n    // 0.2's opaque handle makes every index, including zero, an exact\n    // selection. Backend::Auto accepts any primary device and cannot conflict\n    // with the selected device's vendor backend.\n    Ok((Backend::Auto, Some(device)))\n}\n\n/// Map Handy's whisper accelerator setting to a transcribe-cpp [`Backend`].","sourceCodeStart":1926,"sourceCodeEnd":1962,"githubUrl":"https://github.com/cjpais/Handy/blob/ba10ce1943ef34e93c09494027fc0b9ced2e8a44/src-tauri/src/managers/transcription.rs#L1926-L1962","documentation":"resolve_device_index maps the --device-index flag to a (Backend, gpu_device) pair by searching transcribe_compute_devices() — the registry built by init_transcribe_backend() at startup — for a device with that index. This error means no registered device carries the given index; --list-devices prints exactly the valid index set.","triggerScenarios":"load_model is called with device_index = Some(n) and the registry has no device with index n: index copied from another machine, GPU/driver changed since the registry was built (app not restarted), dynamic backend modules failed to load leaving fewer devices, or a headless machine with no GPU devices registered.","commonSituations":"See trigger scenarios.","solutions":["Run with --list-devices and use one of the printed index values","Omit --device-index entirely to use the persisted accelerator setting (Auto/CPU/GPU)","Restart the app after GPU/driver changes so the device registry is rebuilt","Check startup logs for 'Failed to initialize transcribe-cpp backends' — module load failure shrinks the registry"],"exampleFix":"// before: hardcode an index that may not exist on this machine\nmanager.load_model(&model_id, Some(3))?;\n\n// after: resolve against the live registry first\nlet valid: Vec<usize> = describe_compute_devices()\n    .iter()\n    .filter_map(|d| d.split_whitespace().next().and_then(|s| s.strip_prefix(\"index=\")?.parse().ok()))\n    .collect();\nlet idx = if valid.contains(&3) { Some(3) } else { None };\nmanager.load_model(&model_id, idx)?;","handlingStrategy":"validation","validationCode":"// resolve --device-index against the live registry before load_model()\nlet valid: Vec<usize> = describe_compute_devices().iter()\n    .filter_map(|d| d.split(' ').find(|p| p.starts_with(\"index=\"))\n    .and_then(|p| p[6..].parse().ok())\n    .collect();\nlet device_index = valid.contains(&requested).then_some(requested);","typeGuard":"fn valid_device_index(requested: usize) -> Option<usize> {\n    describe_compute_devices().iter().any(|d| {\n        d.starts_with(&format!(\"index={requested} \"))\n    }).then_some(requested)\n}","tryCatchPattern":"if let Err(e) = manager.load_model(&model_id, Some(idx)) {\n    if e.to_string().contains(\"No compute device with index\") {\n        // fall back to the persisted accelerator instead of a hard index\n        manager.load_model(&model_id, None)?;\n    }\n}","preventionTips":["Always derive --device-index from a fresh --list-devices run on the same machine","Restart the app after GPU or driver changes so the registry is rebuilt","Prefer omitting --device-index unless you must pin a specific GPU","Check startup logs for backend init failures that shrink the device list"],"tags":["rust","cli","device-index","gpu","validation"],"backgroundTag":"invalid-device-index","analyzedSha":"ba10ce1943ef34e93c09494027fc0b9ced2e8a44","analyzedAt":"2026-08-22T10:26:11.153Z","contentChangedAt":"2026-08-22T10:26:11.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}