From c6fa66300467e9545da7dd1eede0b6ef8c8dbbda Mon Sep 17 00:00:00 2001 From: Dakshesh Sharma Date: Tue, 20 Oct 2026 13:00:38 +0530 Subject: [PATCH] Fix minGPT multi-node GPU count check --- distributed/minGPT-ddp/mingpt/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/distributed/minGPT-ddp/mingpt/main.py b/distributed/minGPT-ddp/mingpt/main.py index 8fdca56667..8c9c2ee67e 100644 --- a/distributed/minGPT-ddp/mingpt/main.py +++ b/distributed/minGPT-ddp/mingpt/main.py @@ -50,7 +50,9 @@ def main(cfg: DictConfig): destroy_process_group() if __name__ == "__main__": - _min_gpu_count = 2 + # torchrun sets LOCAL_WORLD_SIZE to the number of workers on this node. + # Each local worker needs its own accelerator. + _min_gpu_count = int(os.environ.get("LOCAL_WORLD_SIZE", "2")) if not verify_min_gpu_count(min_gpus=_min_gpu_count): print(f"Unable to locate sufficient {_min_gpu_count} gpus to run this example. Exiting.") sys.exit()