vscode debug大工程(torchrun,deepspeed等)最优雅的方式

reference: https://github.com/yuanzhoulvpi2017/vscode_debug_transformers

程序入口

import os
import debugpy
if os.environ.get('CODE_MODE') == 'debug':
    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(('localhost', 9501))
        print('Waiting for debugger attach')
        debugpy.wait_for_client()
    except Exception as e:
        pass

launch.json

{
    "name": "sh_file_debug",
    "type": "debugpy",
    "request": "attach",
    "connect": {
        "host": "localhost",
        "port": 9501
    }
},
posted @ 2024-11-07 00:33  sleepy_turtle  阅读(551)  评论(0)    收藏  举报