zhijian-liu / torchpack

A neural network training interface based on PyTorch, with a focus on flexibility
https://pypi.org/project/torchpack/
MIT License
61 stars 15 forks source link

How to debug code launched with torchpack? #7

Closed cslxiao closed 3 years ago

cslxiao commented 3 years ago

How to debug code launched with torchpack in IDE such as VSCode? Thx.

zhijian-liu commented 3 years ago

I'm not sure about this as I usually debugged the code with prints.

victor000000 commented 2 years ago

try CUDA_VISIBLE_DEVICES=1 MASTER_HOST=localhost:1235 python xxxxx.py {args}

oliver0922 commented 1 year ago

Same question as above. How to debug code launched with torchpack in IDE such as VSCode?

SibylGao commented 1 year ago

Maybe Pdb is what you need: import pdb; pdb.set_trace()

antragoudaras commented 1 year ago

I did the following to debug my code with torchpack in vscode:

  1. Add the following lines in your code at the begging after all imports have finished:

Screenshot from 2023-03-22 20-09-52

  1. Set breaking points in your code where you wish.

  2. Create the following launch.json file under .vscode folder

Screenshot from 2023-03-22 20-11-38

  1. In a command line run your torchpack command like you just want to run the code and not debug, i.e.: torchpack dist-run -np 1 python tools/test.py configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/convfuser.yaml pretrained/bevfusion-det.pth --eval bbox

  2. Go to the Run And Debug Window and press the attach button

Screenshot from 2023-03-22 20-14-15

These steps should allow you to debug your code with torchpack!