invoke-ai/InvokeAI · error · ValueError

Invalid generation_devices value '{v}'. Use 'auto' or a list

Error message

Invalid generation_devices value '{v}'. Use 'auto' or a list of devices, e.g. ['cuda:0', 'cuda:1'].

What it means

validate_generation_devices accepts either the literal string 'auto' or an explicit list of device strings. Supplying a non-'auto' string is rejected outright because iterating it would match character-by-character ('c','u','d'...) and produce a confusing per-character error. Empty lists and malformed device names have their own messages (errors 586/587).

Source

Thrown at invokeai/app/services/config/config_default.py:290

        default=None, description="API key for Seedream image generation."
    )
    external_seedream_base_url: Optional[str] = Field(
        default=None, description="Base URL override for Seedream image generation."
    )

    # fmt: on

    model_config = SettingsConfigDict(env_prefix="INVOKEAI_", env_ignore_empty=True)

    @field_validator("generation_devices")
    @classmethod
    def validate_generation_devices(cls, v: Union[str, list[str]]) -> Union[str, list[str]]:
        if v == "auto":
            return v
        # A non-"auto" string would otherwise be iterated character-by-character below (rejecting
        # 'c' from "cuda:0"), producing a confusing error. Require an explicit list instead.
        if isinstance(v, str):
            raise ValueError(
                f"Invalid generation_devices value '{v}'. Use 'auto' or a list of devices, e.g. ['cuda:0', 'cuda:1']."
            )
        if len(v) == 0:
            raise ValueError("generation_devices cannot be an empty list. Use 'auto' or a list of devices.")
        pattern = re.compile(r"^(cpu|mps|xpu(:\d+)?|cuda(:\d+)?)$")
        for device in v:
            if not pattern.match(device):
                raise ValueError(
                    f"Invalid generation device '{device}'. Valid values are 'auto', 'cpu', 'mps', 'cuda', 'cuda:N', "
                    "'xpu', or 'xpu:N'."
                )
        return v

    @field_validator("base_url")
    @classmethod
    def validate_base_url(cls, v: Optional[str]) -> Optional[str]:
        """Normalize the reverse-proxy base path: ensure a single leading slash, no trailing slash.

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Change the value to 'auto' to let InvokeAI pick devices automatically
  2. Use an explicit YAML list: generation_devices: ['cuda:0', 'cuda:1']
  3. For env vars, use JSON list syntax, e.g. GENERATION_DEVICES='["cuda:0","cuda:1"]'

Example fix

// before (invokeai.yaml)
generation_devices: cuda:0
// after
generation_devices:
  - cuda:0
  - cuda:1
Defensive patterns

Strategy: validation

Validate before calling

v = cfg.generation_devices
assert v == 'auto' or isinstance(v, list), "generation_devices must be 'auto' or a list like ['cuda:0']"

Try / catch

try:
    cfg = InvokeAIAppConfig(**overrides)
except ValueError as e:
    if 'generation_devices' in str(e):
        overrides['generation_devices'] = 'auto'
        cfg = InvokeAIAppConfig(**overrides)

Prevention

When it happens

Trigger: Configuring generation_devices as a plain string like 'cuda:0' or 'cuda' instead of a list, e.g. in invokeai.yaml or via the corresponding env var; quoting a list so YAML/env parsing yields a single string.

Common situations: Users following older docs that allowed a single device string; setting env GENERATION_DEVICES='cuda:0' without list syntax; YAML unquoted values interpreted as string rather than sequence.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/9005367c8813149a. Report an issue: GitHub.