报错信息

torch.distributed.DistNetworkError: The server socket has failed to listen on any local network address. The server socket has failed to bind to [::]:23456 (errno: 98 - Address already in use). The server socket has failed to bind to 0.0.0.0:23456 (errno: 98 - Address already in use).

原因

这个错误表明 PyTorch Lightning 在尝试设置分布式环境时无法绑定到默认的端口23456,因为该端口已经被其他进程占用了。

解决方法

修改 Lightning 中 DDP 的端口设置。尝试在设置环境变量 MASTER_PORT 时指定一个空闲的端口号。在启动程序之前,执行以下命令:

export MASTER_PORT=<your_desired_port_number>

例如:

export MASTER_PORT=12345

然后再次运行你的程序。这样 PyTorch Lightning 在设置分布式环境时就会使用你指定的端口,而不是默认的23456。

Logo

一站式 AI 云服务平台

更多推荐