配置debug
用vscode打开pytorch源码,run侧边栏中新建launch.json
选择attach using process ID类型 的上面那个remote attach(因为我尝试了attach process id总是搞不定。。)
配置好port和host,再在python代码中加入
此时执行便会等待attach:
(pytorch) xueruini@nico2:~/onion_rain/pytorch/object_detection$ python train.py --json experiments/thyroid_v4_train.json --device 0,1 --debug
47592
Waiting for debugger attach at 127.0.0.1:12345 ......
train.py:226: DeprecationWarning: 'redirect_output' setting via enable_attach will be deprecated in the future versions of the debugger. This can be set using redirectOutput in Launch config in VS Code, using Tee output option in Visual Studio, or debugOptions configuration for any client.
ptvsd.enable_attach(address=(host, port), redirect_output=True)
此时选择remote attach即可进行debug