{"record":{"id":"6b00a5f385ea6880","repo":"Lightning-AI/pytorch-lightning","slug":"no-supported-gpu-backend-found-6b00a5","errorCode":null,"errorMessage":"No supported gpu backend found!","messagePattern":"No supported gpu backend found!","errorType":"validation","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":341,"sourceCode":"                else self._accelerator_flag\n            )\n            raise MisconfigurationException(\n                f\"`Trainer(devices={self._devices_flag!r})` value is not a valid input\"\n                f\" using {accelerator_name} accelerator.\"\n            )\n\n    @staticmethod\n    def _choose_auto_accelerator() -> str:\n        \"\"\"Choose the accelerator type (str) based on availability.\"\"\"\n        return _select_auto_accelerator()\n\n    @staticmethod\n    def _choose_gpu_accelerator_backend() -> str:\n        if MPSAccelerator.is_available():\n            return \"mps\"\n        if CUDAAccelerator.is_available():\n            return \"cuda\"\n        raise MisconfigurationException(\"No supported gpu backend found!\")\n\n    def _set_parallel_devices_and_init_accelerator(self) -> None:\n        if isinstance(self._accelerator_flag, Accelerator):\n            self.accelerator: Accelerator = self._accelerator_flag\n        else:\n            self.accelerator = AcceleratorRegistry.get(self._accelerator_flag)\n        accelerator_cls = self.accelerator.__class__\n\n        if not accelerator_cls.is_available():\n            available_accelerator = [\n                acc_str\n                for acc_str in self._accelerator_types\n                if AcceleratorRegistry[acc_str][\"accelerator\"].is_available()\n            ]\n            raise MisconfigurationException(\n                f\"`{accelerator_cls.__qualname__}` can not run on your system\"\n                \" since the accelerator is not available. The following accelerator(s)\"\n                \" is available and can be passed into `accelerator` argument of\"","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L323-L359","documentation":"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.","triggerScenarios":"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.","commonSituations":"Running GPU training in CI containers without CUDA; CUDA driver/toolkit mismatch after system updates; Apple/AMD machines without proper backends.","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')"],"exampleFix":"# before\ntrainer = Trainer(accelerator=\"gpu\", devices=1)\n# after\naccel = \"gpu\" if torch.cuda.is_available() else \"cpu\"\ntrainer = Trainer(accelerator=accel, devices=1)","handlingStrategy":"fallback","validationCode":"import torch\nif not (torch.backends.mps.is_available() or torch.cuda.is_available()):\n    accelerator = \"cpu\"\nelse:\n    accelerator = \"gpu\"\ntrainer = Trainer(accelerator=accelerator)","typeGuard":"def gpu_backend_available() -> bool:\n    import torch\n    return torch.cuda.is_available() or getattr(torch.backends, \"mps\", None) and torch.backends.mps.is_available()","tryCatchPattern":"from lightning.pytorch.utilities.exceptions import MisconfigurationException\ntry:\n    trainer = Trainer(accelerator=\"gpu\")\nexcept MisconfigurationException as e:\n    if \"No supported gpu backend\" in str(e):\n        trainer = Trainer(accelerator=\"cpu\")\n    else:\n        raise","preventionTips":["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"],"tags":["pytorch-lightning","gpu","cuda","environment"],"backgroundTag":"cuda-not-available","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}