※ 해당 글을 작성하게 된 이유,
작성한 코드가 에러 없이 깔끔하게 실행되면 참 좋겠지만 이런 경우는 거의 없기에, 이를 마주하고 해결해 나가는 것은 매우 중요합니다.
변수의 내용을 직접 확인함으로써 1부터 100까지 작성하는 데 많은 도움을 주는 방식이기에 공유코자 글로 남깁니다.
Process
Step1. launch.json 파일 생성
Step2. Configuration
Step3. Breakpoint
Step4. Debug console
Visual Studio Code Docs ( related to 'Debugging' )
Visual Studio Code Variables Reference
Step1. launch.json 파일 생성
Step2. Configuration
- 기본 내용
{
// 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
}
]
}
- 주로 사용하는 내용
{
"name": "SOLIDER-SwinT: train.py",
"type": "python",
"request": "launch",
"console": "integratedTerminal",
"program": "${workspaceFolder}${pathSeparator}SOLIDER-HumanParsing${pathSeparator}train.py",
"cwd": "${workspaceFolder}",
"justMyCode": false,
"env": {
"CUDA_VISIBLE_DEVICES": "0, 1, 2, 3"
},
"args": [
"--arch", "swin_tiny",
"--imagenet-pretrain", "./SOLIDER/log/swin_tiny.pth",
"--batch-size", "32",
"--input-size", "572,384",
"--log-dir", "./logs/lip_solider_swin_tiny"
]
}
Step3. Breakpoint
- F5 Continue
- Ctrl + Shift + F5 Restart
Step4. Debug console
실행 중간에 breakpoint 를 찍어 실행을 멈추게 한 후, 원하는 변수 값 확인 가능
- WATCH 로도 변수 값을 확인할 수 있으나 실행을 재개하면 내용이 전부 사라짐 ( Figure1 참고 )
'Useful Information > VSCode' 카테고리의 다른 글
[ VSCode ] Python Interactive window (0) | 2023.10.30 |
---|