invoke-ai/InvokeAI · error · ValueError

generation_devices cannot be an empty list. Use 'auto' or a

Error message

generation_devices cannot be an empty list. Use 'auto' or a list of devices.

What it means

validate_generation_devices explicitly rejects an empty list for generation_devices; an empty sequence carries no device selection, so the validator forces the user to either say 'auto' or name at least one device.

Source

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

    )

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

        Empty values and a bare `/` normalize to `None` (feature disabled).

        Reject base paths whose first segment collides with a real route prefix (`/api`, `/ws`, ...):
        such a value silently bricks the server in both proxy styles (the sub-path rewrite and

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Set generation_devices: auto to use automatic device selection
  2. Provide at least one valid device in the list, e.g. ['cuda:0'] or ['cpu']
  3. If the list is built dynamically, fall back to 'auto' when the computed list is empty

Example fix

// before
generation_devices: []
// after
generation_devices:
  - cuda:0
Defensive patterns

Strategy: validation

Validate before calling

devices = cfg.generation_devices
if isinstance(devices, list) and len(devices) == 0:
    devices = 'auto'  # normalize before constructing config

Try / catch

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

Prevention

When it happens

Trigger: Passing generation_devices: [] in the YAML config, GENERATION_DEVICES='[]' via env, or programmatically constructing InvokeAIAppConfig(generation_devices=[]).

Common situations: Commenting out all list entries in YAML leaving an empty key; template configs with placeholder lists left empty; code that builds the list dynamically and ends up with zero devices.

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/aaae8f39e3d72d22. Report an issue: GitHub.