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

This page may help you. Profiling your PyTorch Module — PyTorch Tutorials 2.0.1+cu117 documentation