This method is verified!
https://code.visualstudio.com/docs/python/debugging
开始
vscode cmd: show run and debug.
click ‘create launch.json’
A file is created.
If you wanna run shell script for python like this:
1CUDA_VISIBLE_DEVICES=0 python cloth_funnels/run_sim.py \2name="demo-single" \3load=models/longsleeve_canonicalized_alignment.pth \4eval_tasks=assets/tasks/longsleeve-single.hdf5 \5eval=True \6num_processes=1 \7episode_length=10 \8wandb=disabled \9fold_finish=True \10dump_visualizations=True
Add args like, [tested ok]:
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=8303875 "version": "0.2.0",6 "configurations": [7 {8 "name": "Python: 当前文件",9 "type": "python",10 "request": "launch",11 "program": "${file}",12 // "program": "${workspaceFolder}/script/eval_policy.py", // 这样也行13 "console": "integratedTerminal",14 "args": ["name=\"demo-single\"",15 "load=models/longsleeve_canonicalized_alignment.pth",14 collapsed lines
16 "eval_tasks=assets/tasks/longsleeve-single.hdf5",17 "eval=True",18 "num_processes=1",19 "episode_length=10",20 "wandb=disabled",21 "fold_finish=True",22 "dump_visualizations=True"],23 "env": {24 "CUDA_VISIBLE_DEVICES": "0",25 "HYDRA_FULL_ERROR": "1",26 },27 }28 ]29}
Switch to the file you want to run (as in launch.json we by default designate “Run current file”, so you have to switch to the exact file to run).
Add a breakpoint,
Click the green delta in “Run python and debug” menu,
Everything is well! And watch params in the menu!
Remote
Using vscode-ssh is also ok to run python debug in remote machine.