Skip to content

Commit

Permalink
[Fix] --local-rank for PyTorch >= 2.0.0 (open-mmlab#2051)
Browse files Browse the repository at this point in the history
Co-authored-by: rangoliu <[email protected]>
  • Loading branch information
youqingxiaozhua and liuwenran committed Oct 19, 2023
1 parent dfe6767 commit 9384f4b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def parse_args():
choices=['none', 'pytorch', 'slurm', 'mpi'],
default='none',
help='job launcher')
parser.add_argument('--local_rank', type=int, default=0)
# When using PyTorch version >= 2.0.0, the `torch.distributed.launch`
# will pass the `--local-rank` parameter to `tools/train.py` instead
# of `--local_rank`.
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
args = parser.parse_args()
if 'LOCAL_RANK' not in os.environ:
os.environ['LOCAL_RANK'] = str(args.local_rank)
Expand Down

0 comments on commit 9384f4b

Please sign in to comment.