Skip to content

Commit

Permalink
Merge branch 'master' into differentiability_3
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 4, 2021
2 parents 1377864 + fde4e45 commit 9f81e6c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/helpers/testers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@
EXTRA_DIM = 3
THRESHOLD = 0.5

MAX_PORT = 8100
START_PORT = 8088
CURRENT_PORT = START_PORT


def setup_ddp(rank, world_size):
""" Setup ddp environment """
global CURRENT_PORT

os.environ["MASTER_ADDR"] = "localhost"
os.environ["MASTER_PORT"] = "8088"
os.environ["MASTER_PORT"] = str(CURRENT_PORT)

CURRENT_PORT += 1
if CURRENT_PORT > MAX_PORT:
CURRENT_PORT = START_PORT

if torch.distributed.is_available() and sys.platform not in ("win32", "cygwin"):
torch.distributed.init_process_group("gloo", rank=rank, world_size=world_size)
Expand Down

0 comments on commit 9f81e6c

Please sign in to comment.