how to run 'python -m' command in pycharm?

for example, i need to debug a python file in pycharm ,and the full command to run this script in terminal is  :

python -m torch.distributed.launch --nproc_per_node=2 test_net.py TEST.IMS_PER_BATCH 16

 what and where should i set or edit  in pycharm so that i can debug this script in pycharm?

 

thank you !!

4 comments
Comment actions Permalink

Hi,

Try creating a run configuration in PyCharm, specify `-m torch.distributed.launch --nproc_per_node=2` as interpreter options, and `TEST.IMS_PER_BATCH 16` as script parameters. Set test_net.py as a script path.

Then debug using this configuration.

0
Comment actions Permalink

hi ,thanks for your reply!

i set the above configuration as you said ,and i can run it in pycharm but i still can not debug it,and the error message is the following:

 

/home/xwj/anaconda3/envs/MR/bin/python -m torch.distributed.launch --nproc_per_node=2 /home/xwj/pycharm-2018.3.6/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 43655 --file /media/xwj/Programm/Python/maskrcnn-benchmark/train_copy.py MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN 2000 SOLVER.IMS_PER_BATCH 2
Traceback (most recent call last):
File "/home/xwj/pycharm-2018.3.6/helpers/pydev/pydevd.py", line 1574, in main
setup = process_command_line(sys.argv)
File "/home/xwj/pycharm-2018.3.6/helpers/pydev/_pydevd_bundle/pydevd_command_line_handling.py", line 145, in process_command_line
raise ValueError("Unexpected option: " + argv[i])
ValueError: Unexpected option: --local_rank=1
Usage:
pydevd.py --port N [(--client hostname) | --server] --file executable [file_options]
Traceback (most recent call last):
File "/home/xwj/pycharm-2018.3.6/helpers/pydev/pydevd.py", line 1574, in main
setup = process_command_line(sys.argv)
File "/home/xwj/pycharm-2018.3.6/helpers/pydev/_pydevd_bundle/pydevd_command_line_handling.py", line 145, in process_command_line
raise ValueError("Unexpected option: " + argv[i])
ValueError: Unexpected option: --local_rank=0
Usage:
pydevd.py --port N [(--client hostname) | --server] --file executable [file_options]

Process finished with exit code 0

 

what does this mean and what should i do?

thank you!!

 

0
Comment actions Permalink

Sorry, my last recommendation wasn't correct. Please try the following instead:

In your run/debug configuration, specify Module name (instead of script path), and enter the module you want to run, in our case `torch.distributed.launch`.

Everything else goes to parameters, namely:

--nproc_per_node=2 test_net.py TEST.IMS_PER_BATCH 16

Kindly try it and let me know the results.

1

Please sign in to leave a comment.