系列文章目录
【分布式训练 debug】VS Code Debug 技巧:launch.json实用参数
【分布式训练(2)】深入理解 DeepSpeed 的 ZeRO 内存优化策略 (三阶段的区别)
问题描述
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "debugpy",
"request": "launch",
"module": "accelerate.commands.launch",
"args": [
"--config_file", "/path/accelerate_config.yaml",
"/path/train_model.py",
"--config", "/path/train_config.yaml"
],
"console": "integratedTerminal",
"env": {
"CUDA_VISIBLE_DEVICES": "7"
},
"justMyCode": false
}
]
}
用以上 launch.json 对 accelerator + deepspeed 的训练代码进行 debug,结果完全无法连接。

问题排查过程
- deepspeed 的网络配置?❌
- 更改配置没有任何影响,依旧报错。
- launch.json 写错的问题?❌
- 之前用相同的 json,能过正常跑通。
- 如果不用 accelerate + deepspeed,能跑,但会等特别久。而且不用 deepspeed 又会 oom,完全没法调代码。😭
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "debugpy",
"request": "launch",
"program": "/path/train_model.py",
"args": [
"--config", "/path/train_config.yaml"
],
"console": "integratedTerminal",
"env": {
"CUDA_VISIBLE_DEVICES": "7"
},
"justMyCode": false
}
]
}
原因分析+解决方案
原因分析:
- 用 “program” 等很久,但能正常跑,但用 “module” 没等多久时间久报错如前文的图 “time out”。
- 很可能是 vs code 对 “module” 和 “program” 的等待时长不一样?
- 解决方案:(1)延长时间?- 过了下 vs code 官方文档也没找到怎么做⏸️(2)直接用 “program” ✅
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "debugpy",
"request": "launch",
"program": "/path/bin/accelerate",
"args": [
"launch",
"--config_file", "/path/accelerate_config.yaml",
"/path/train_model.py",
"--config", "/path/train_config.yaml"
],
"console": "integratedTerminal",
"env": {
"CUDA_VISIBLE_DEVICES": "7"
},
"justMyCode": false
}
]
}
灵感来源:https://blog.csdn.net/qq_19716143/article/details/136035839
- 这篇博客直接用的是 “program”: “/path/bin/deepspeed”

】accelerator + deepspeed debug 报错 “Timed out waiting for debuggee to spawn“ 解决方法✅&spm=1001.2101.3001.5002&articleId=142928867&d=1&t=3&u=51404ff7f7244303a6cdcd5da7ccfa25)
850

被折叠的 条评论
为什么被折叠?



