Skip to content

Commit 7f7461e

Browse files
committed
tests: use a temporary file:// as rendezvous
Before the change, the test case used a hardcoded port number to run the tests. This made the test fail in some environments where the port number was occupied (either by a different service or - more likely - by a second run of the project test suite). Signed-off-by: Ihar Hrachyshka <[email protected]>
1 parent 5296a13 commit 7f7461e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/attr/test_data_parallel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import copy
55
import os
66
from enum import Enum
7+
import tempfile
78
from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Type
89

910
import torch
@@ -300,9 +301,8 @@ def _get_dp_attr_methods(
300301
if torch.cuda.is_available() and torch.cuda.device_count() != 0:
301302

302303
# Distributed Data Parallel env setup
303-
os.environ["MASTER_ADDR"] = "localhost"
304-
os.environ["MASTER_PORT"] = "29500"
305-
dist.init_process_group(backend="gloo", rank=0, world_size=1)
304+
f = tempfile.NamedTemporaryFile(delete=False)
305+
dist.init_process_group(backend="gloo", init_method=f"file://{f.name}", rank=0, world_size=1)
306306

307307
class DataParallelTest(BaseTest, metaclass=DataParallelMeta):
308308
@classmethod

0 commit comments

Comments
 (0)