首页 前端知识 VSCode 利用 debugpy 调试 python项目【launch.json】

VSCode 利用 debugpy 调试 python项目【launch.json】

2024-06-25 23:06:01 前端知识 前端哥 168 926 我要收藏

一、修改launch.json(VSCode

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true
        }
    ]
}

注销掉代码:

// "program": "${file}",
// "console": "integratedTerminal",

添加代码:

"connect": {
	"host": "localhost", 
	"port": 50678 
}
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "debugpy",
            "request": "attach",
            // "program": "${file}",
            // "console": "integratedTerminal",
            "justMyCode": false,
            "connect": {
                "host": "localhost", 
                "port": 50678 
            }
        }
    ]
}

二、train.sh

利用debugpy调试,设定调试用的GPU标号为2

#!/usr/bin/env bash
 
#修改gpu编号
export CUDA_VISIBLE_DEVICES=2,3
python3 -m debugpy --listen 50678  --wait-for-client train.py

三、在vscode的terminal运行:

sh -x train.sh

运行完成shell脚本后停在python脚本调用的入口,点击F5进入python调试。

转载请注明出处或者链接地址:https://www.qianduange.cn//article/13559.html
标签
编辑器ide
评论
发布的文章

爱心

2024-06-27 17:06:24

表白代码

2024-06-27 16:06:42

html5 css3 前端基础认识。

2024-06-26 23:06:18

CFT Show 信息收集篇

2024-06-26 23:06:28

html插入视频的方法

2024-06-20 00:06:46

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!