cjpais/Handy · error · anyhow::Error

No compute device with index {index} (see --list-devices)

Error message

No compute device with index {index} (see --list-devices)

What it means

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).

Source

Thrown at src-tauri/src/managers/transcription.rs:1918

            let vram_mb = d.memory_total / (1024 * 1024);
            format!(
                "index={} kind={} name={} vram={}MB",
                idx, d.kind, name, vram_mb
            )
        })
        .collect()
}

/// Resolve a `--list-devices` registry index to the (backend, gpu_device) pair
/// for a transcribe-cpp model load (the `--device-index` flag). The
/// backend is set explicitly from the device's kind, so there's no "index 0 =
/// auto" ambiguity. Errors if the index isn't a registered, loadable device.
fn resolve_device_index(index: usize) -> Result<(Backend, i32)> {
    let device = transcribe_compute_devices()
        .into_iter()
        .find(|d| d.index == Some(index))
        .ok_or_else(|| {
            anyhow::anyhow!("No compute device with index {index} (see --list-devices)")
        })?;
    let backend = match device.kind.as_str() {
        "cpu" => Backend::Cpu,
        "metal" => Backend::Metal,
        "cuda" => Backend::Cuda,
        "vulkan" => Backend::Vulkan,
        other => {
            return Err(anyhow::anyhow!(
                "Device index {index} has kind '{other}', which cannot host a model"
            ))
        }
    };
    // gpu_device is a registry index used only by GPU backends; CPU ignores it.
    let gpu_device = if matches!(backend, Backend::Cpu) {
        0
    } else {
        index as i32
    };

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Run the app with --list-devices and use an index printed by THIS run
  2. Remove --device-index to fall back to the persisted accelerator setting (Auto/CPU/GPU) instead of pinning a device
  3. 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
  4. Update scripts to resolve the index dynamically (list devices, then pick) instead of hard-coding it

Example fix

# before
handy --transcribe-file clip.wav --model whisper-small --device-index 3  # may be stale

# after
handy --list-devices   # note valid indexes for this run, e.g. index=0 kind=cpu, index=1 kind=vulkan
handy --transcribe-file clip.wav --model whisper-small --device-index 1
Defensive patterns

Strategy: validation

Validate before calling

// Validate --device-index against THIS run's registry before loading
let valid: Vec<usize> = transcribe_compute_devices().iter().filter_map(|d| d.index).collect();
anyhow::ensure!(valid.contains(&index),
    "--device-index {index} is not registered this run; valid indexes: {valid:?} (run with --list-devices)");

Type guard

// Narrow the CLI value to a registered device before use
fn registered_device(index: usize) -> Option<ComputeDevice> {
    transcribe_compute_devices().into_iter().find(|d| d.index == Some(index))
}

Try / catch

match tm.load_model_with_device(&model_id, Some(index)) {
    Err(e) if e.to_string().contains("No compute device with index") => {
        eprintln!("{}", describe_compute_devices().join("\n")); // show valid indexes, then exit
        std::process::exit(2);
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of cjpais/Handy@98a4d80cce (2026-08-16). Data as JSON: /api/errors/ed6534959a0b0893. Report an issue: GitHub.