{"record":{"id":"ad7dabebab75e6cf","repo":"Lightning-AI/pytorch-lightning","slug":"the-start-method-self-start-method-is-not-ava-ad7dab","errorCode":null,"errorMessage":"The start method '{self._start_method}' is not available on this platform. Available methods are: {', '.join(mp.get_all_start_methods())}","messagePattern":"The start method '(.+?)' is not available on this platform\\. Available methods are: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/strategies/launchers/multiprocessing.py","lineNumber":79,"sourceCode":"          before calling ``Trainer.fit``.\n\n    Args:\n        strategy: A reference to the strategy that is used together with this launcher.\n        start_method: The method how to start the processes.\n            - 'spawn': The default start method. Requires all objects to be pickleable.\n            - 'fork': Preferable for IPython/Jupyter environments where 'spawn' is not available. Not available on\n              the Windows platform for example.\n            - 'forkserver': Alternative implementation to 'fork'.\n\n    \"\"\"\n\n    def __init__(\n        self, strategy: \"pl.strategies.ParallelStrategy\", start_method: Literal[\"spawn\", \"fork\", \"forkserver\"] = \"spawn\"\n    ) -> None:\n        self._strategy = strategy\n        self._start_method = start_method\n        if start_method not in mp.get_all_start_methods():\n            raise ValueError(\n                f\"The start method '{self._start_method}' is not available on this platform. Available methods are:\"\n                f\" {', '.join(mp.get_all_start_methods())}\"\n            )\n        self.procs: list[mp.Process] = []\n        self._already_fit = False\n\n    @property\n    @override\n    def is_interactive_compatible(self) -> bool:\n        # The start method 'spawn' is not supported in interactive environments\n        # The start method 'fork' is the only one supported in Jupyter environments, with constraints around CUDA\n        # initialization. For more context, see https://github.com/Lightning-AI/pytorch-lightning/issues/7550\n        return self._start_method == \"fork\"\n\n    @override\n    def launch(self, function: Callable, *args: Any, trainer: Optional[\"pl.Trainer\"] = None, **kwargs: Any) -> Any:\n        \"\"\"Launches processes that run the given function in parallel.\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/strategies/launchers/multiprocessing.py#L61-L97","documentation":"The _MultiProcessingLauncher validates its start_method against multiprocessing.get_all_start_methods() at construction time. If the requested start method (e.g. 'forkserver' or 'spawn') is not available on the current platform (notably Windows only supports 'spawn'), it raises immediately.","triggerScenarios":"Constructing a launcher (indirectly via a strategy that uses multiprocessing, e.g. DDPStrategy with launchers) with start_method='fork' or 'forkserver' on Windows or macOS where that method is unavailable; explicitly instantiating _MultiProcessingLauncher(strategy, start_method='fork') on Windows.","commonSituations":"Code developed on Linux (fork works) run on Windows; notebooks/scripts hardcoding fork for performance; older tutorials passing start_method explicitly.","solutions":["Use start_method='spawn' (the default, available everywhere), or omit the argument","If you must pick a method, choose from multiprocessing.get_all_start_methods() on the target platform","On Windows, restructure code to be spawn-safe (guard with if __name__ == '__main__' and picklable top-level functions)"],"exampleFix":"# before\nlauncher = _MultiProcessingLauncher(strategy, start_method=\"fork\")  # on Windows\n\n# after\nimport multiprocessing as mp\nlauncher = _MultiProcessingLauncher(strategy, start_method=next(iter(sorted(mp.get_all_start_methods() & {\"fork\", \"forkserver\", \"spawn\"})), \"spawn\"))","handlingStrategy":"validation","validationCode":"import multiprocessing as mp\nmethod = start_method if start_method in mp.get_all_start_methods() else \"spawn\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to 'spawn' for cross-platform code","Check mp.get_all_start_methods() in test/setup code on each target platform","Never hardcode 'fork' in code that may run on Windows"],"tags":["multiprocessing","start-method","platform","pytorch-lightning"],"backgroundTag":"multiprocessing-start-method-unavailable","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}