使用分布式的时候报错:
RuntimeError: NCCL error in: ../torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp:957, invalid usage, NCCL version 21.0.3
ncclInvalidUsage: This usually reflects invalid usage of NCCL library (such as too many async ops, too many collectives at once, mixing streams in a group, etc).
可以考虑:
1. CUDA_VISIBLE_DEVICES=0,1,(举个例子)前面的变量名有没有敲错;
2. CUDA、nccl、pytorch版本是否兼容,我问了一下chatgpt我的是兼容的;
3. local_rank的问题,我是这一种,代码一开始默认设置了--local_rank=0,后面用的一直是这个args.local_rank,也没有更新,解决办法是在获取args之后,对它进行更新:
if 'LOCAL_RANK' not in os.environ:
os.environ['LOCAL_RANK'] = str(args.local_rank)
args.local_rank = int(os.environ['LOCAL_RANK'])
以及其他博主的解决办法>_<