WandB 退出错误说明
错误信息
Exception ignored in atexit callback: <function _start_and_connect_service.<locals>.teardown_atexit> BrokenPipeError: [Errno 32] Broken pipe Exception ignored in: <function ResourceTracker.__del__ at 0x...> AttributeError: '_thread.RLock' object has no attribute '_recursion_count'错误性质
这些是非关键错误(Non-critical errors),发生在程序正常退出时的清理过程中。
为什么会出现?
- 程序正常完成:训练已经成功完成,wandb 已经同步了所有数据
- 清理阶段问题:在程序退出时,wandb 和 multiprocess 尝试清理资源
- 异步操作冲突:退出时某些异步操作(如网络连接关闭)可能已经中断
错误分析
1. WandB BrokenPipeError
BrokenPipeError: [Errno 32] Broken pipe原因:
- WandB 在程序退出时尝试关闭连接
- 但连接可能已经被系统或其他进程关闭
- 这是清理阶段的竞态条件
影响:
- ✅不影响训练结果
- ✅不影响 checkpoint 保存
- ✅WandB 数据已经同步(从日志可以看到 “Synced 5 W&B file(s)”)
2. ResourceTracker AttributeError
AttributeError: '_thread.RLock' object has no attribute '_recursion_count'原因:
- Python multiprocess 的资源跟踪器在清理时的问题
- 可能是 Python 版本兼容性问题
- 发生在
__del__析构函数中
影响:
- ✅不影响训练结果
- ✅不影响数据保存
- ⚠️ 可能有一些资源没有完全清理(但会被系统回收)
验证训练是否成功
检查 checkpoint
# 查看最新的 checkpointls-lh /root/autodl-tmp/verl/checkpoints/verl_example_gsm8k/deepseek_llm_7b_function_rm/# 查看 checkpoint 内容cat/root/autodl-tmp/verl/checkpoints/verl_example_gsm8k/deepseek_llm_7b_function_rm/latest_checkpointed_iteration.txt检查 WandB 记录
从日志可以看到:
- ✅ WandB 已经同步:
Synced 5 W&B file(s) - ✅ 可以查看运行记录:
https://wandb.ai/xxx/verl_example_gsm8k/runs/ny8yfg5m
检查训练指标
从日志可以看到训练指标已经记录:
actor/pg_loss: 0.00065actor/ppo_kl: 0.00011critic/advantages/mean: 0.0- 等等
解决方案
方案 1: 忽略错误(推荐)
这些错误不影响训练结果,可以安全忽略。训练已经成功完成。
方案 2: 抑制 WandB 退出错误
如果不想看到这些错误信息,可以在脚本中添加:
# 在脚本开头添加exportWANDB_SILENT=true# 或exportPYTHONWARNINGS="ignore::UserWarning"方案 3: 更新依赖
如果问题持续,可以尝试更新相关包:
pipinstall--upgrade wandb multiprocess方案 4: 使用环境变量抑制
# 抑制 atexit 错误exportPYTHONUNBUFFERED=1# 或者在 Python 代码中importwarnings warnings.filterwarnings('ignore')总结
- ✅训练成功完成:所有数据已保存
- ✅WandB 同步成功:数据已上传
- ✅Checkpoint 已保存:可以继续训练或使用
- ⚠️退出错误:不影响结果,可以忽略
建议
- 检查训练结果:确认 checkpoint 和 WandB 记录正常
- 继续使用:这些错误不影响后续使用
- 如果担心:可以查看 WandB 网页确认所有数据都已记录
相关链接
- WandB 运行记录:https://wandb.ai/xxx/verl_example_gsm8k/runs/ny8yfg5m
- 项目页面:https://wandb.ai/xxx/verl_example_gsm8k