diff --git a/src/lerobot/configs/train.py b/src/lerobot/configs/train.py index e3d354691..7f32f255c 100644 --- a/src/lerobot/configs/train.py +++ b/src/lerobot/configs/train.py @@ -101,6 +101,14 @@ class TrainPipelineConfig(HubMixin): batch_size: int = 8 prefetch_factor: int = 4 persistent_workers: bool = True + # DataLoader multiprocessing start method. "spawn" is the safe default on + # Linux because workers do not inherit fork-time state from the parent — + # "fork" can crash with non-fork-safe libraries that the parent has loaded + # (e.g. PyAV / torchcodec / ffmpeg) with errors like + # `multiprocessing.context.AuthenticationError: digest received was wrong`, + # `Pin memory thread exited unexpectedly`, or random worker segfaults. + # See https://github.com/huggingface/lerobot/issues/2488. + dataloader_multiprocessing_context: str = "spawn" steps: int = 100_000 # Run policy in the simulation environment every N steps to measure reward/success (0 = disabled). env_eval_freq: int = 20_000 diff --git a/src/lerobot/scripts/lerobot_train.py b/src/lerobot/scripts/lerobot_train.py index ec5565cf4..bca92629a 100644 --- a/src/lerobot/scripts/lerobot_train.py +++ b/src/lerobot/scripts/lerobot_train.py @@ -475,6 +475,7 @@ def train(cfg: TrainPipelineConfig, accelerator: "Accelerator | None" = None): collate_fn=collate_fn, prefetch_factor=cfg.prefetch_factor if cfg.num_workers > 0 else None, persistent_workers=cfg.persistent_workers and cfg.num_workers > 0, + multiprocessing_context=cfg.dataloader_multiprocessing_context if cfg.num_workers > 0 else None, ) # Build eval dataloader if a held-out split exists