Skip to content

Commit

Permalink
fix hostname -I for macOS #6497 (#6990)
Browse files Browse the repository at this point in the history
BUGFIX for Apple Silicon hostname
#6497

---------

Signed-off-by: Fabien Dupont <[email protected]>
Signed-off-by: Olatunji Ruwase <[email protected]>
Signed-off-by: Logan Adams <[email protected]>
Signed-off-by: inkcherry <[email protected]>
Signed-off-by: Roman Fitzjalen <[email protected]>
Co-authored-by: Logan Adams <[email protected]>
Co-authored-by: Fabien Dupont <[email protected]>
Co-authored-by: Olatunji Ruwase <[email protected]>
Co-authored-by: Liangliang Ma <[email protected]>
Co-authored-by: inkcherry <[email protected]>
  • Loading branch information
6 people authored Feb 12, 2025
1 parent a5b6395 commit 549e11d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions deepspeed/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,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:
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())
master_addr = comm.bcast(master_addr, root=0)

# Determine local rank by assuming hostnames are unique
Expand Down

0 comments on commit 549e11d

Please sign in to comment.