Skip to content

Commit 20987e5

Browse files
[Feats]: allow setting local-rank for pytorch 2.0 (#2387)
1 parent c9fd5a6 commit 20987e5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/train.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def parse_args():
5050
choices=['none', 'pytorch', 'slurm', 'mpi'],
5151
default='none',
5252
help='job launcher')
53-
parser.add_argument('--local_rank', type=int, default=0)
53+
# When using PyTorch version >= 2.0.0, the `torch.distributed.launch`
54+
# will pass the `--local-rank` parameter to `tools/train.py` instead
55+
# of `--local_rank`.
56+
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
5457
args = parser.parse_args()
5558
if 'LOCAL_RANK' not in os.environ:
5659
os.environ['LOCAL_RANK'] = str(args.local_rank)

0 commit comments

Comments
 (0)