cjpais/Handy · error · anyhow::Error

No compute device with index

Error message

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

What it means

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.

Solutions

  1. Run with --list-devices and use one of the printed index values
  2. Omit --device-index entirely to use the persisted accelerator setting (Auto/CPU/GPU)
  3. Restart the app after GPU/driver changes so the device registry is rebuilt
  4. Check startup logs for 'Failed to initialize transcribe-cpp backends' — module load failure shrinks the registry

Example fix

// before: hardcode an index that may not exist on this machine
manager.load_model(&model_id, Some(3))?;

// after: resolve against the live registry first
let valid: Vec<usize> = describe_compute_devices()
    .iter()
    .filter_map(|d| d.split_whitespace().next().and_then(|s| s.strip_prefix("index=")?.parse().ok()))
    .collect();
let idx = if valid.contains(&3) { Some(3) } else { None };
manager.load_model(&model_id, idx)?;
Defensive patterns

Strategy: validation

Validate before calling

// resolve --device-index against the live registry before load_model()
let valid: Vec<usize> = describe_compute_devices().iter()
    .filter_map(|d| d.split(' ').find(|p| p.starts_with("index="))
    .and_then(|p| p[6..].parse().ok())
    .collect();
let device_index = valid.contains(&requested).then_some(requested);

Type guard

fn valid_device_index(requested: usize) -> Option<usize> {
    describe_compute_devices().iter().any(|d| {
        d.starts_with(&format!("index={requested} "))
    }).then_some(requested)
}

Try / catch

if let Err(e) = manager.load_model(&model_id, Some(idx)) {
    if e.to_string().contains("No compute device with index") {
        // fall back to the persisted accelerator instead of a hard index
        manager.load_model(&model_id, None)?;
    }
}

Prevention

When it happens

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

Common situations: See trigger scenarios.

Related errors


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

Appendix: source

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

            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 an exact opaque device handle
/// for a transcribe-cpp model load (the `--device-index` flag). In 0.2 index 0
/// is an exact selection too; only an omitted index requests automatic device
/// selection. Errors if the index isn't a registered, loadable primary device.
fn resolve_device_index(index: usize) -> Result<(Backend, Option<transcribe_cpp::Device>)> {
    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)")
        })?;
    if matches!(
        device.device_type,
        transcribe_cpp::DeviceType::Accel | transcribe_cpp::DeviceType::Unknown
    ) {
        return Err(anyhow::anyhow!(
            "Device index {index} ({}) cannot host a model",
            device.kind
        ));
    }

    // 0.2's opaque handle makes every index, including zero, an exact
    // selection. Backend::Auto accepts any primary device and cannot conflict
    // with the selected device's vendor backend.
    Ok((Backend::Auto, Some(device)))
}

/// Map Handy's whisper accelerator setting to a transcribe-cpp [`Backend`].

View on GitHub (pinned to ba10ce1943)