Skip to content

Commit 83e7cc2

Browse files
authored
[Fix] Fix accepting an unexpected argument local-rank in PyTorch 2.0 (open-mmlab#2813)
1 parent db09c54 commit 83e7cc2

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
@@ -97,7 +97,10 @@ def parse_args():
9797
type=float,
9898
default=0.5,
9999
help='Opacity of painted segmentation map. In (0, 1] range.')
100-
parser.add_argument('--local_rank', type=int, default=0)
100+
# When using PyTorch version >= 2.0.0, the `torch.distributed.launch`
101+
# will pass the `--local-rank` parameter to `tools/train.py` instead
102+
# of `--local_rank`.
103+
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
101104
args = parser.parse_args()
102105
if 'LOCAL_RANK' not in os.environ:
103106
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
@@ -86,7 +86,10 @@ def parse_args():
8686
choices=['none', 'pytorch', 'slurm', 'mpi'],
8787
default='none',
8888
help='job launcher')
89-
parser.add_argument('--local_rank', type=int, default=0)
89+
# When using PyTorch version >= 2.0.0, the `torch.distributed.launch`
90+
# will pass the `--local-rank` parameter to `tools/train.py` instead
91+
# of `--local_rank`.
92+
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
9093
parser.add_argument(
9194
'--auto-resume',
9295
action='store_true',

0 commit comments

Comments
 (0)