在使用 torch.distributed.run 进行 PyTorch 分布式训练时,你可能会遇到以下错误信息:

WARNING:torch.distributed.run:*****************************************
Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
train.py: error: unrecognized arguments: --local-rank=1 convformer_b36_in21ft1k.pth

train.py: error: unrecognized arguments: --local-rank=0 convformer_b36_in21ft1k.pth
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 2) local_rank: 0 (pid: 31168) of binary: /home/lh/anaconda3/envs/metaformer/bin/python3

这个错误表明你的 train.py 文件中出现了无法识别的参数 --local-rank=1--local-rank=0。这是因为 torch.distributed.run 会自动添加这些参数,所以你不需要手动传入。

为了解决这个问题,你需要检查 train.py 文件中的参数设置,并确保这些参数是有效的。具体来说,你需要:

  1. 确认你的代码中是否手动传递了 --local-rank 参数。 如果是,请删除它,因为 torch.distributed.run 会自动处理。
  2. 检查你的 train.py 文件中是否使用了其他需要 local_rank 信息的代码。 如果有,你需要确保这些代码使用的是 torch.distributed.get_rank()torch.distributed.get_world_size() 来获取 local_rank 信息,而不是手动传入参数。
  3. 查看 train.py 的文档或示例以了解正确的参数使用方法。 确保你的代码遵循官方文档的指导。

如果以上方法都无法解决问题,请确保你使用的 PyTorch 版本和 torch.distributed.run 的版本匹配,并尝试更新或降级版本进行测试。

解决 PyTorch 分布式训练中的

原文地址: https://www.cveoy.top/t/topic/qzsF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录