Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hostname -I for macOS #6497 #6990

Merged
merged 14 commits into from
Feb 12, 2025
10 changes: 7 additions & 3 deletions deepspeed/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,13 @@ def mpi_discovery(distributed_port=TORCH_DISTRIBUTED_DEFAULT_PORT, verbose=True)
master_addr = None
if rank == 0:
import shlex
hostname_cmd = shlex.split("hostname -I")
result = subprocess.check_output(hostname_cmd)
master_addr = result.decode('utf-8').split()[0]
try:
loadams marked this conversation as resolved.
Show resolved Hide resolved
hostname_cmd = shlex.split("hostname -I")
result = subprocess.check_output(hostname_cmd)
master_addr = result.decode('utf-8').split()[0]
except subprocess.CalledProcessError: # hostname -I not available (e.g. on macOS)
import socket
master_addr = socket.gethostbyname(socket.gethostname())
loadams marked this conversation as resolved.
Show resolved Hide resolved
master_addr = comm.bcast(master_addr, root=0)

# Determine local rank by assuming hostnames are unique
Expand Down
Loading