这个专栏记录我学习/科研过程中遇到的一些小问题以及解决方案,一些问题可能比较蠢请见谅。自用,仅供参考。
------------------------------------------------------------------------------------
Linux报错Address already in use(OpenGait)
在服务器上跑OpenGait时出现了如下报错:
RuntimeError: The server socket has failed to listen on any local network address. The server socket has failed to bind to [::]:29500 (errno: 98 - Address already in use). The server socket has failed to bind to … (errno: 98 - Address already in use).
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 opengait/main.py --cfgs ./configs/gait/gait.yaml --phase train --log_to_file
这种情况通常发生在使用了命令运行工作1(例如python -m torch.distributed.launch --nproc_per_node=2 work_A.py
),又在同一个账号上命令运行工作2(例如python -m torch.distributed.launch --nproc_per_node=2 work_B.py
)。报错原因显然是默认端口被占用,需要重新指定端口号。上面报错时的端口号是29500,需要重新指定端口,例如29501,在OpenGait中使用master_port来指定端口:
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 --master_port='29501' opengait/main.py --cfgs ./configs/gait/gait.yaml --phase train --log_to_file
代码开始运行。