Lightning-AI/pytorch-lightning · error · MisconfigurationException
No supported gpu backend found!
Error message
No supported gpu backend found!
What it means
When Trainer(accelerator='gpu') is chosen, the connector probes for a usable GPU backend (MPS, then CUDA). If neither MPS nor CUDA reports available, it raises this MisconfigurationException because 'gpu' cannot resolve to a concrete backend.
Source
Thrown at src/lightning/pytorch/trainer/connectors/accelerator_connector.py:341
else self._accelerator_flag
)
raise MisconfigurationException(
f"`Trainer(devices={self._devices_flag!r})` value is not a valid input"
f" using {accelerator_name} accelerator."
)
@staticmethod
def _choose_auto_accelerator() -> str:
"""Choose the accelerator type (str) based on availability."""
return _select_auto_accelerator()
@staticmethod
def _choose_gpu_accelerator_backend() -> str:
if MPSAccelerator.is_available():
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"View on GitHub (pinned to 9fed5c27d2)
Solutions
- Verify CUDA availability with torch.cuda.is_available(); fix driver/toolkit installation or GPU visibility (CUDA_VISIBLE_DEVICES)
- Use accelerator='auto' so Lightning falls back to CPU when no GPU exists
- Explicitly run on CPU: Trainer(accelerator='cpu')
Example fix
# before trainer = Trainer(accelerator="gpu", devices=1) # after accel = "gpu" if torch.cuda.is_available() else "cpu" trainer = Trainer(accelerator=accel, devices=1)
Defensive patterns
Strategy: fallback
Validate before calling
import torch
if not (torch.backends.mps.is_available() or torch.cuda.is_available()):
accelerator = "cpu"
else:
accelerator = "gpu"
trainer = Trainer(accelerator=accelerator) Type guard
def gpu_backend_available() -> bool:
import torch
return torch.cuda.is_available() or getattr(torch.backends, "mps", None) and torch.backends.mps.is_available() Try / catch
from lightning.pytorch.utilities.exceptions import MisconfigurationException
try:
trainer = Trainer(accelerator="gpu")
except MisconfigurationException as e:
if "No supported gpu backend" in str(e):
trainer = Trainer(accelerator="cpu")
else:
raise Prevention
- Gate GPU usage on torch.cuda.is_available() in entry scripts
- Use accelerator='auto' so Lightning falls back gracefully
- Verify CUDA_VISIBLE_DEVICES and driver health in containers before GPU runs
When it happens
Trigger: Trainer(accelerator='gpu') on a machine with no NVIDIA GPU/CUDA toolkit or Apple Silicon GPU; broken CUDA installs where CUDAAccelerator.is_available() is False.
Common situations: Running GPU training in CI containers without CUDA; CUDA driver/toolkit mismatch after system updates; Apple/AMD machines without proper backends.
Related errors
- GPUs requested but none are available.
- str(_TRANSFORMER_ENGINE_AVAILABLE)
- Cannot re-initialize CUDA in forked subprocess. To use CUDA
- Lightning can't create new processes if CUDA is already init
- GPUs should be a list
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/6b00a5f385ea6880.
Report an issue: GitHub.