How can I use pdb in PyCharm for the pytorch source code?

I want to tour pytorch source code with pycharm.

So I installed by

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch

MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

Even in /anaconda3/lib/python3.6/site-packages/pytorch source I can’t use pdb.set_trace()

How can I do that?

Try to install pytorch in develop mode:
pip uninstall torch
pip uninstall torch
pip uninstall torch # yes, we're just trying to get rid of your previous installations
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop

In develop mode, you can add (python) breakpoints the code under the pytorch repo and those will be triggered.

1 Like