How to profile memory footprint and breakdowns

I was making inference using Pytorch and I wanna get the memory footprint in the process of inference and breakdown it into seperate parts to analyse for further study. How can I do that and thanks