Lightning-AI/pytorch-lightning · error · MisconfigurationException

` ` can not run on your system since the accelerator is not…

Error message

`{accelerator_cls.__qualname__}` can not run on your system since the accelerator is not available. The following accelerator(s) is available and can be passed into `accelerator` argument of `Trainer`: {available_accelerator}.

What it means

The requested accelerator class reports is_available() == False on this system. The error lists which accelerators ARE available so you can pick one. Raised during accelerator initialization from the registry.

Solutions

  1. Use one of the accelerators listed in the error message
  2. Set accelerator='auto' to let Lightning pick an available one
  3. Fix the environment: install CUDA/ROCm/MPS support so the desired accelerator becomes available

Example fix

# before
trainer = Trainer(accelerator="cuda", devices=1)
# after
trainer = Trainer(accelerator="auto", devices="auto")
Defensive patterns

Strategy: fallback

Validate before calling

from lightning.pytorch.accelerators import CPUAccelerator
accelerators = [a for a in (CPUAccelerator,) if a.is_available()]  # extend with CUDA/MPS as needed
accel_cls = MyAccelerator if MyAccelerator.is_available() else CPUAccelerator
trainer = Trainer(accelerator=accel_cls)

Type guard

def accelerator_available(accel_cls) -> bool:
    return bool(accel_cls.is_available())

Try / catch

from lightning.pytorch.utilities.exceptions import MisconfigurationException
try:
    trainer = Trainer(accelerator="cuda")
except MisconfigurationException as e:
    if "is not available" in str(e):
        trainer = Trainer(accelerator="auto")
    else:
        raise

Prevention

When it happens

Trigger: Trainer(accelerator=MPSAccelerator()) or accelerator='mps' on non-Apple hardware; CUDAAccelerator on a CPU-only box; also custom registered accelerators whose is_available() returns False.

Common situations: Sharing configs across heterogeneous machines (mac vs linux vs GPU nodes); deprecated/uninstalled accelerator backends (e.g. HPU/TPU without supporting libraries).

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/43b2c0107b1b33d5. Report an issue: GitHub.

Appendix: source

Thrown at src/lightning/pytorch/trainer/connectors/accelerator_connector.py:356

            return "mps"
        if CUDAAccelerator.is_available():
            return "cuda"
        raise MisconfigurationException("No supported gpu backend found!")

    def _set_parallel_devices_and_init_accelerator(self) -> None:
        if isinstance(self._accelerator_flag, Accelerator):
            self.accelerator: Accelerator = self._accelerator_flag
        else:
            self.accelerator = AcceleratorRegistry.get(self._accelerator_flag)
        accelerator_cls = self.accelerator.__class__

        if not accelerator_cls.is_available():
            available_accelerator = [
                acc_str
                for acc_str in self._accelerator_types
                if AcceleratorRegistry[acc_str]["accelerator"].is_available()
            ]
            raise MisconfigurationException(
                f"`{accelerator_cls.__qualname__}` can not run on your system"
                " since the accelerator is not available. The following accelerator(s)"
                " is available and can be passed into `accelerator` argument of"
                f" `Trainer`: {available_accelerator}."
            )

        self._set_devices_flag_if_auto_passed()
        self._devices_flag = accelerator_cls.parse_devices(self._devices_flag)
        if not self._parallel_devices:
            self._parallel_devices = accelerator_cls.get_parallel_devices(self._devices_flag)

    def _set_devices_flag_if_auto_passed(self) -> None:
        if self._devices_flag != "auto":
            return
        if (
            _IS_INTERACTIVE
            and isinstance(self.accelerator, CUDAAccelerator)
            and self.accelerator.auto_device_count() > 1

View on GitHub (pinned to 9fed5c27d2)