VScode를 이용하여 Debugging을 위하여 argparse와 별도의 parameters를 입력으로 받을 수 없는 VScode를 위하여 아래와 같이 설계하면 Debugging이 가능하다.
아래와 같이 launch.json 파일을 만들어 주면 끝!
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug test.py", //파일 이름
"type": "python", //Script type
"request": "launch",
// "module": "torch.distributed.launch", //-m torch.distributed.launch
"program": "${workspaceFolder}/tools/test.py", //실행하고자 하는 파일
"cwd": "${workspaceFolder}",
"args": [
"local_configs/feedformer/B0/notaformer.b0.512x512.ade.160k.py", //CONFIG
"checkpoints/ade20k/B0/feedformer_b0_ade20k.pth", //CHECKPOINT
],
"env": {
"PYTHONPATH": "${workspaceFolder}/..:${env:PYTHONPATH}",
"--master_port": "29500", //PORT
"--nproc_per_node": "2", //GPUS
"--launcher": "pytorch",
},
"console": "integratedTerminal"
}
]
}
위 json 파일은 아래 shell file (.sh)과 동일한 역할을 한다. (위는 Debugging 아래는 Linux command를 통한 Run을 수행한다)
#./tools/dist_test.sh 파일 예시
#!/usr/bin/env bash
CONFIG=$1
CHECKPOINT=$2
GPUS=$3
PORT=${PORT:-29500}
PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \
python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \
$(dirname "$0")/test.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4}
이후 아래와 같이
./tools/dist_test.sh local_configs/feedformer/B0/feedformer.b0.512x512.ade.160k.py checkpoints/ade20k/B0/feedformer_b0_ade20k.pth 2
Linux terminal에서 수행해주면 된다.
끝!
How to setup everything (0) | 2022.11.27 |
---|---|
Github 간단 사용법 (0) | 2022.11.08 |
댓글 영역