Skip to content

Commit 73df26d

Browse files
authored
[Enhancement] Accepts local-rank in train.py and test.py (#1806)
* [Enhancement] Accepts local-rank * add * update
1 parent f47cff5 commit 73df26d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tools/test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ def parse_args():
4545
help='Job launcher')
4646
parser.add_argument(
4747
'--tta', action='store_true', help='Test time augmentation')
48-
parser.add_argument('--local_rank', type=int, default=0)
48+
# When using PyTorch version >= 2.0.0, the `torch.distributed.launch`
49+
# will pass the `--local-rank` parameter to `tools/test.py` instead
50+
# of `--local_rank`.
51+
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
4952
args = parser.parse_args()
5053
if 'LOCAL_RANK' not in os.environ:
5154
os.environ['LOCAL_RANK'] = str(args.local_rank)

tools/train.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def parse_args():
4141
choices=['none', 'pytorch', 'slurm', 'mpi'],
4242
default='none',
4343
help='Job launcher')
44-
parser.add_argument('--local_rank', type=int, default=0)
44+
# When using PyTorch version >= 2.0.0, the `torch.distributed.launch`
45+
# will pass the `--local-rank` parameter to `tools/train.py` instead
46+
# of `--local_rank`.
47+
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
4548
args = parser.parse_args()
4649
if 'LOCAL_RANK' not in os.environ:
4750
os.environ['LOCAL_RANK'] = str(args.local_rank)

0 commit comments

Comments
 (0)