2 pytorch network_error ai_generated partial

运行时错误:[torch.distributed] 排名 0 上的 AllReduce 超时(超时时间:600)

RuntimeError: [torch.distributed] AllReduce timed out in rank 0 (timeout: 600)

ID: pytorch/nccl-timeout-during-allreduce

其他格式: JSON · Markdown 中文 · English
80%修复率
82%置信度
1证据数
2024-01-10首次发现

版本兼容性

版本状态引入弃用备注
pytorch>=2.1.0 active
nccl>=2.18.0 active

根因分析

NCCL allreduce 操作由于网络拥塞、工作节点缓慢或崩溃、或节点间 NCCL 版本不匹配而超时。

English

NCCL allreduce operation timed out due to network congestion, a slow or crashed worker, or mismatched NCCL versions across nodes.

generic

官方文档

https://pytorch.org/docs/stable/distributed.html#troubleshooting

解决方案

  1. 使用 `nccl-tests` 或 `ping` 检查所有节点之间的网络连接。确保所有节点可以在所需端口(例如 29500)上通信。然后设置 `NCCL_SOCKET_IFNAME=eth0` 以指定正确的网络接口。
  2. 减小批量大小或模型大小以降低通信量,或使用梯度累积减少 allreduce 频率。
  3. 如果 NCCL 有问题,切换到 Gloo 后端进行 allreduce:`torch.distributed.init_process_group(backend='gloo', ...)`。注意:Gloo 可能较慢但在某些网络上更稳定。

无效尝试

常见但无效的做法:

  1. 70% 失败

    If the underlying issue (e.g., network congestion or slow node) persists, the operation will still fail after the longer timeout.

  2. 90% 失败

    The network issue is likely persistent; a restart only resets the state temporarily.

  3. 95% 失败

    While logging helps diagnosis, it does not resolve the timeout itself.