Skip to main content

远程调试

远程调试py文件

python -m debugpy --listen 0.0.0.0:5678 --wait-for-client test.py
#test.py
def hello():
print("hello")

hello()

vscode 配置launch.json:

{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Attach to SGLang Container",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "x.x.x.x",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/sgl-workspace/sglang"
}
],
"justMyCode": false
}
]
}

远程调试sglang

# 正常启动方式
python3 -m sglang.launch_server --model-path /data_workspace/st/models/DeepSeek-R1-Distill-Qwen-1.5B --tp 2 --trust-remote-code --mem-fraction-static 0.66

# debug启动
export CUDA_VISIBLE_DEVICES=1
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m sglang.launch_server --model-path /data_workspace/wt/models/DeepSeek-R1-Distill-Qwen-1.5B --tp 1 --trust-remote-code --mem-fraction-static 0.66

在vscode中打上断点,然后执行调试。 比如:sglang/python/sglang/launch_server.py入口中打上断点。

curl http://localhost:30000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-r1-distill-qwen-1.5b",
"messages": [
{"role": "user", "content": "hi"}
]
}'