Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Set dummy MASTER_HOST when launched without torchpack dist-run (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
RalphMao authored Sep 4, 2021
1 parent fe461b0 commit 828fe85
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions torchpack/distributed/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ def init(backend: int = 'nccl',

if 'MASTER_HOST' in os.environ:
master_host = 'tcp://' + os.environ['MASTER_HOST']
torch.distributed.init_process_group(backend=backend,
init_method=master_host,
timeout=timeout,
world_size=_world_size,
rank=_world_rank)
else:
from torchpack.launch.launchers.drunner import get_free_tcp_port
master_host = 'tcp://localhost:{}'.format(get_free_tcp_port())
print("Distributed environment not detected, fall back to default")
torch.distributed.init_process_group(backend=backend,
init_method=master_host,
timeout=timeout,
world_size=_world_size,
rank=_world_rank)


def size() -> int:
Expand Down

0 comments on commit 828fe85

Please sign in to comment.