I debugged pytorch C++ extension in source code by gdb python debgger. But when I run “import torch”, this command is very slow in gdb python. So how to make gdb faster when debugging source code?
Hey!
There are a few possible reasons for this:
- It is downloading pytorch’s dependencies’ symbols which can be slow. You can skip these or make sure they get properly cached
- You using a debug build of pytorch which is known to be very big and slow. You can use https://github.com/pytorch/pytorch/blob/e14026bc2a6cd80bedffead77a5d7b75a37f8e67/setup.py#L11-L12C53 to only enable symbols for the few files you care about
- pytorch itself takes a couple seconds to import. That is expected even outside of gdb
Hope this helps!
Thank you so much, i will have a try.
How to check dependencies’ symbols is cached properly or not? If not, how to cache or skip these symbols in pytorch build?
I think you would have to check with your version of gdb.
For me, this often happens when trying to load libc and the like which can take a bit to download. If you don’t see a downloading message from gdb though, it is most likely something else.
1 Like