Lightning-AI/pytorch-lightning · error · ValueError
The start method '{self._start_method}' is not available on
Error message
The start method '{self._start_method}' is not available on this platform. Available methods are: {', '.join(mp.get_all_start_methods())} What it means
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.
Source
Thrown at src/lightning/pytorch/strategies/launchers/multiprocessing.py:79
before calling ``Trainer.fit``.
Args:
strategy: A reference to the strategy that is used together with this launcher.
start_method: The method how to start the processes.
- 'spawn': The default start method. Requires all objects to be pickleable.
- 'fork': Preferable for IPython/Jupyter environments where 'spawn' is not available. Not available on
the Windows platform for example.
- 'forkserver': Alternative implementation to 'fork'.
"""
def __init__(
self, strategy: "pl.strategies.ParallelStrategy", start_method: Literal["spawn", "fork", "forkserver"] = "spawn"
) -> None:
self._strategy = strategy
self._start_method = start_method
if start_method not in mp.get_all_start_methods():
raise ValueError(
f"The start method '{self._start_method}' is not available on this platform. Available methods are:"
f" {', '.join(mp.get_all_start_methods())}"
)
self.procs: list[mp.Process] = []
self._already_fit = False
@property
@override
def is_interactive_compatible(self) -> bool:
# The start method 'spawn' is not supported in interactive environments
# The start method 'fork' is the only one supported in Jupyter environments, with constraints around CUDA
# initialization. For more context, see https://github.com/Lightning-AI/pytorch-lightning/issues/7550
return self._start_method == "fork"
@override
def launch(self, function: Callable, *args: Any, trainer: Optional["pl.Trainer"] = None, **kwargs: Any) -> Any:
"""Launches processes that run the given function in parallel.
View on GitHub (pinned to 9fed5c27d2)
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)
Example fix
# before
launcher = _MultiProcessingLauncher(strategy, start_method="fork") # on Windows
# after
import multiprocessing as mp
launcher = _MultiProcessingLauncher(strategy, start_method=next(iter(sorted(mp.get_all_start_methods() & {"fork", "forkserver", "spawn"})), "spawn")) Defensive patterns
Strategy: validation
Validate before calling
import multiprocessing as mp method = start_method if start_method in mp.get_all_start_methods() else "spawn"
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Code developed on Linux (fork works) run on Windows; notebooks/scripts hardcoding fork for performance; older tutorials passing start_method explicitly.
Related errors
- The start method '{self._start_method}' is not available on
- Cannot re-initialize CUDA in forked subprocess. To use CUDA
- Lightning can't create new processes if CUDA is already init
- Launching multiple processes with the 'spawn' start method r
- Device should be CPU, got {device} instead.
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/ad7dabebab75e6cf.
Report an issue: GitHub.