{"record":{"id":"2dcb9ad2fe209d53","repo":"Lightning-AI/pytorch-lightning","slug":"you-selected-an-invalid-accelerator-name-acceler-2dcb9a","errorCode":null,"errorMessage":"You selected an invalid accelerator name: `accelerator={accelerator!r}`. Available names are: auto, {', '.join(self._accelerator_types)}.","messagePattern":"You selected an invalid accelerator name: `accelerator=(.+?)`\\. Available names are: auto, (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":204,"sourceCode":"        if isinstance(strategy, str):\n            strategy = strategy.lower()\n\n        self._strategy_flag = strategy\n\n        if strategy != \"auto\" and strategy not in self._registered_strategies and not isinstance(strategy, Strategy):\n            raise ValueError(\n                f\"You selected an invalid strategy name: `strategy={strategy!r}`.\"\n                \" It must be either a string or an instance of `lightning.pytorch.strategies.Strategy`.\"\n                \" Example choices: auto, ddp, ddp_spawn, deepspeed, ...\"\n                \" Find a complete list of options in our documentation at https://lightning.ai\"\n            )\n\n        if (\n            accelerator not in self._accelerator_types\n            and accelerator not in (\"auto\", \"gpu\")\n            and not isinstance(accelerator, Accelerator)\n        ):\n            raise ValueError(\n                f\"You selected an invalid accelerator name: `accelerator={accelerator!r}`.\"\n                f\" Available names are: auto, {', '.join(self._accelerator_types)}.\"\n            )\n\n        # MPS accelerator is incompatible with DDP family of strategies. It supports single-device operation only.\n        is_ddp_str = isinstance(strategy, str) and \"ddp\" in strategy\n        is_deepspeed_str = isinstance(strategy, str) and \"deepspeed\" in strategy\n        is_parallel_strategy = isinstance(strategy, ParallelStrategy) or is_ddp_str or is_deepspeed_str\n        is_mps_accelerator = MPSAccelerator.is_available() and (\n            accelerator in (\"mps\", \"auto\", \"gpu\", None) or isinstance(accelerator, MPSAccelerator)\n        )\n        if is_mps_accelerator and is_parallel_strategy:\n            raise ValueError(\n                f\"You set `strategy={strategy}` but strategies from the DDP family are not supported on the\"\n                f\" MPS accelerator. Either explicitly set `accelerator='cpu'` or change the strategy.\"\n            )\n\n        self._accelerator_flag = accelerator","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L186-L222","documentation":"AcceleratorConnector validates the `accelerator` argument against the known accelerator types plus 'auto'/'gpu'. Any unknown string (or non-Accelerator object) raises this ValueError listing valid names.","triggerScenarios":"`Trainer(accelerator='cuda')` (invalid — should be 'gpu'), `accelerator='tpu'` without XLA support, `accelerator=3` or other non-string non-Accelerator values.","commonSituations":"Coming from raw PyTorch/HuggingFace where 'cuda' is the device string; passing torch.device objects or integers; typos like 'gpu '/ 'cpu-'.","solutions":["Use 'auto', 'gpu', 'cpu', 'mps', 'tpu', 'hpu', etc. — specifically replace 'cuda' with 'gpu'.","Or pass an Accelerator instance such as `lightning.pytorch.accelerators.CUDAAccelerator()`.","Alternatively set `devices` and leave accelerator='auto' to let Lightning pick."],"exampleFix":"# before\ntrainer = Trainer(accelerator='cuda', devices=1)\n# after\ntrainer = Trainer(accelerator='gpu', devices=1)","handlingStrategy":"validation","validationCode":"VALID = {'auto', 'gpu', 'cpu', 'mps', 'tpu', 'hpu', 'cuda'}  # normalize 'cuda'->'gpu'\naccel = 'gpu' if accelerator == 'cuda' else accelerator\nassert accel in {'auto','gpu','cpu','mps','tpu','hpu'} or hasattr(accel, 'setup'), f'bad accelerator {accelerator!r}'","typeGuard":"from lightning.pytorch.accelerators import Accelerator\n\ndef is_valid_accelerator(a) -> bool:\n    return isinstance(a, Accelerator) or (isinstance(a, str) and a.lower() in {'auto','gpu','cpu','mps','tpu','hpu'})","tryCatchPattern":"except ValueError as e: if 'invalid accelerator name' in str(e): normalize ('cuda'->'gpu') and retry Trainer construction","preventionTips":["Map device strings from user/CLI input: cuda/gpu -> 'gpu', mps -> 'mps'.","Prefer accelerator='auto' and only set devices."],"tags":["pytorch-lightning","trainer","accelerator","invalid-argument"],"backgroundTag":"invalid-configuration-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}