当前位置:   article > 正文

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

vscode python launch.json

一、修改launch.json(VSCode

  1. {
  2. // Use IntelliSense to learn about possible attributes.
  3. // Hover to view descriptions of existing attributes.
  4. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  5. "version": "0.2.0",
  6. "configurations": [
  7. {
  8. "name": "Python: Current File",
  9. "type": "python",
  10. "request": "launch",
  11. "program": "${file}",
  12. "console": "integratedTerminal",
  13. "justMyCode": true
  14. }
  15. ]
  16. }

注销掉代码:

  1. // "program": "${file}",
  2. // "console": "integratedTerminal",

添加代码:

  1. "connect": {
  2. "host": "localhost",
  3. "port": 50678
  4. }
  1. {
  2. // 使用 IntelliSense 了解相关属性。
  3. // 悬停以查看现有属性的描述。
  4. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  5. "version": "0.2.0",
  6. "configurations": [
  7. {
  8. "name": "Python: Current File",
  9. "type": "debugpy",
  10. "request": "attach",
  11. // "program": "${file}",
  12. // "console": "integratedTerminal",
  13. "justMyCode": false,
  14. "connect": {
  15. "host": "localhost",
  16. "port": 50678
  17. }
  18. }
  19. ]
  20. }

二、train.sh

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

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

三、在vscode的terminal运行:

sh -x train.sh

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/461248
推荐阅读
相关标签
  

闽ICP备14008679号