nvidia-smi is your best bet (when using GPU’s). For CPU’s I’ve found useful psutil.virtual_memory().used
Also, pytorch-summary 426 can take in a model and give estimates for the memory needed for the parameters, forward/backward pass, and the data itself.