vscode 如何debug python torchrun deepspeed
最优雅的方式
安装
- 安装包
pip install debugpy -U
- 安装vscode关于python的相关插件
写配置
一般情况下,大家都是使用deepspeed、torchrun运行代码。参数都特别多,然后都是使用sh xxxx.sh
启动脚本。
在python代码里面(最前面加上这句话)
import debugpy
try:
# 5678 is the default attach port in the VS Code debug configurations. Unless a host and port are specified, host defaults to 127.0.0.1
debugpy.listen(