Skip to content

Commit

Permalink
check port availability only in main launcher for deepspeed/torchrun
Browse files Browse the repository at this point in the history
  • Loading branch information
聂靖入 committed Oct 25, 2023
1 parent 9cd5f8c commit 498e756
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/accelerate/utils/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def prepare_multi_gpu_env(args: argparse.Namespace) -> Dict[str, str]:
if main_process_port is None:
main_process_port = 29500

if is_port_in_use(main_process_port):
need_port_check = num_machines <= 1 or int(args.machine_rank) == 0
if need_port_check and is_port_in_use(main_process_port):
raise ConnectionError(
f"Tried to launch distributed communication on port `{main_process_port}`, but another process is utilizing it. "
"Please specify a different port (such as using the `----main_process_port` flag or specifying a different `main_process_port` in your config file)"
Expand Down

0 comments on commit 498e756

Please sign in to comment.