{"record":{"id":"6817d745331ceee2","repo":"Lightning-AI/pytorch-lightning","slug":"the-strategy-fsdpstrategy-strategy-name-requir","errorCode":null,"errorMessage":"The strategy `{FSDPStrategy.strategy_name}` requires a GPU accelerator, but received `accelerator={self._accelerator_flag!r}`. Please set `accelerator='cuda'`, `accelerator='gpu'`, or pass a `CUDAAccelerator()` instance to use FSDP.","messagePattern":"The strategy `(.+?)` requires a GPU accelerator, but received `accelerator=(.+?)`\\. Please set `accelerator='cuda'`, `accelerator='gpu'`, or pass a `CUDAAccelerator\\(\\)` instance to use FSDP\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":434,"sourceCode":"            else:\n                device = \"cpu\"\n            # TODO: lazy initialized device, then here could be self._strategy_flag = \"single_device\"\n            return SingleDeviceStrategy(device=device)  # type: ignore\n        if len(self._parallel_devices) > 1 and _IS_INTERACTIVE:\n            return \"ddp_fork\"\n        return \"ddp\"\n\n    def _check_strategy_and_fallback(self) -> None:\n        \"\"\"Checks edge cases when the strategy selection was a string input, and we need to fall back to a different\n        choice depending on other parameters or the environment.\"\"\"\n        # current fallback and check logic only apply to user pass in str config and object config\n        # TODO this logic should apply to both str and object config\n        strategy_flag = \"\" if isinstance(self._strategy_flag, Strategy) else self._strategy_flag\n\n        if (\n            strategy_flag in FSDPStrategy.get_registered_strategies() or type(self._strategy_flag) is FSDPStrategy\n        ) and not (self._accelerator_flag in (\"cuda\", \"gpu\") or isinstance(self._accelerator_flag, CUDAAccelerator)):\n            raise ValueError(\n                f\"The strategy `{FSDPStrategy.strategy_name}` requires a GPU accelerator, but received \"\n                f\"`accelerator={self._accelerator_flag!r}`. Please set `accelerator='cuda'`, `accelerator='gpu'`,\"\n                \" or pass a `CUDAAccelerator()` instance to use FSDP.\"\n            )\n        if strategy_flag in _DDP_FORK_ALIASES and \"fork\" not in torch.multiprocessing.get_all_start_methods():\n            raise ValueError(\n                f\"You selected `Trainer(strategy='{strategy_flag}')` but process forking is not supported on this\"\n                f\" platform. We recommend `Trainer(strategy='ddp_spawn')` instead.\"\n            )\n        if strategy_flag:\n            self._strategy_flag = strategy_flag\n\n    def _init_strategy(self) -> None:\n        \"\"\"Instantiate the Strategy given depending on the setting of ``_strategy_flag``.\"\"\"\n        # The validation of `_strategy_flag` already happened earlier on in the connector\n        assert isinstance(self._strategy_flag, (str, Strategy))\n        if isinstance(self._strategy_flag, str):\n            self.strategy = StrategyRegistry.get(self._strategy_flag)","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L416-L452","documentation":"FSDPShardedStrategy (FSDP) in this Lightning version is CUDA-only. If you request FSDP (by name or FSDPStrategy instance) with an accelerator other than cuda/gpu/CUDAAccelerator, a ValueError is raised before strategy setup.","triggerScenarios":"Trainer(strategy='fsdp', accelerator='cpu') or strategy=FSDPStrategy() with accelerator='tpu'/'mps'/'hpu' or auto-resolution to a non-GPU accelerator.","commonSituations":"Running FSDP configs on CPU for debugging; auto accelerator falling back to CPU on machines without GPUs; adapting FSDP tutorials to TPU/MPS.","solutions":["Ensure a GPU is used: accelerator='cuda' (and verify torch.cuda.is_available())","For CPU debugging, switch strategy to 'ddp' or None and revisit FSDP only on GPU","For non-CUDA sharding, consider DeepSpeed or other strategies supporting your backend"],"exampleFix":"# before\ntrainer = Trainer(strategy=\"fsdp\", accelerator=\"cpu\")\n# after\ntrainer = Trainer(strategy=\"fsdp\", accelerator=\"cuda\")  # requires available GPUs","handlingStrategy":"validation","validationCode":"import torch\nif strategy in (\"fsdp\", FSDPStrategy) and not torch.cuda.is_available():\n    strategy = \"ddp\"  # or raise early with a clear message\ntrainer = Trainer(strategy=strategy, accelerator=accelerator)","typeGuard":"def fsdp_usable(strategy) -> bool:\n    import torch\n    from lightning.pytorch.strategies import FSDPStrategy\n    name = strategy if isinstance(strategy, str) else type(strategy).__name__\n    return not (\"fsdp\" in name.lower()) or torch.cuda.is_available()","tryCatchPattern":"try:\n    trainer = Trainer(strategy=\"fsdp\", accelerator=accelerator)\nexcept ValueError as e:\n    if \"requires a GPU accelerator\" in str(e):\n        trainer = Trainer(strategy=\"ddp\", accelerator=accelerator)\n    else:\n        raise","preventionTips":["Check torch.cuda.is_available() before selecting FSDP","Parameterize strategy per environment instead of hard-coding fsdp"],"tags":["pytorch-lightning","fsdp","strategy","cuda-only"],"backgroundTag":"strategy-accelerator-incompatible","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}