{"record":{"id":"2d2273b2c8a4fb64","repo":"Lightning-AI/pytorch-lightning","slug":"you-selected-trainer-strategy-strategy-flag","errorCode":null,"errorMessage":"You selected `Trainer(strategy='{strategy_flag}')` but process forking is not supported on this platform. We recommend `Trainer(strategy='ddp_spawn')` instead.","messagePattern":"You selected `Trainer\\(strategy='(.+?)'\\)` but process forking is not supported on this platform\\. We recommend `Trainer\\(strategy='ddp_spawn'\\)` instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":440,"sourceCode":"        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)\n        else:\n            self.strategy = self._strategy_flag\n\n    def _check_and_init_precision(self) -> Precision:\n        self._validate_precision_choice()\n        if isinstance(self._precision_plugin_flag, Precision):","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L422-L458","documentation":"DDP fork-based strategies (names in _DDP_FORK_ALIASES like 'ddp_fork', 'fork') require the 'fork' process start method, which is unavailable on this platform (notably Windows, where only spawn is offered). The connector raises ValueError at config time.","triggerScenarios":"Trainer(strategy='ddp_fork') on Windows or any platform where torch.multiprocessing.get_all_start_methods() lacks 'fork'.","commonSituations":"Cross-platform code developed on Linux/macOS and run on Windows; tutorials recommending ddp_fork for Jupyter that fail on Windows setups.","solutions":["Use the recommended alternative: Trainer(strategy='ddp_spawn')","In notebooks on supported platforms use 'ddp_notebook'; otherwise prefer plain 'ddp' in scripts"],"exampleFix":"# before\ntrainer = Trainer(strategy=\"ddp_fork\")\n# after\ntrainer = Trainer(strategy=\"ddp_spawn\")","handlingStrategy":"fallback","validationCode":"import platform, torch.multiprocessing as mp\nif strategy in (\"ddp_fork\", \"fork\") and \"fork\" not in mp.get_all_start_methods():\n    strategy = \"ddp_spawn\"\ntrainer = Trainer(strategy=strategy)","typeGuard":"def fork_strategy_supported(strategy) -> bool:\n    import torch.multiprocessing as mp\n    return strategy not in (\"ddp_fork\", \"fork\") or \"fork\" in mp.get_all_start_methods()","tryCatchPattern":"try:\n    trainer = Trainer(strategy=\"ddp_fork\")\nexcept ValueError as e:\n    if \"forking is not supported\" in str(e):\n        trainer = Trainer(strategy=\"ddp_spawn\")\n    else:\n        raise","preventionTips":["Never default to ddp_fork in cross-platform code; prefer ddp_spawn or ddp","Detect Windows via platform.system() and adjust strategy"],"tags":["pytorch-lightning","ddp-fork","windows","platform-unsupported"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}