How could I know whether a function in Pytorch allocates new memory or not?
Recently, I got stuck in a situation that, in my model, the input data really consumed a lot of memory. And this lead to a lot of memory usage when I operate the data in my network layers. I really want to know whether the operations will allocate new memory block or not. I saw the pytorch doc only found how to use the function. I wonder is there a doc or some websites or anything else official to help me out. For example, will functions like view(), permute() or contiguous() allocate new memory block or not and how do you know that. It really caught me, thanks for helping.

If you are running on a GPU, the best way to check memory consumption is to use the linux command nvidia-smi. You can call this in jupyter-notebook using !nvidia-smi. This way, after any Pytorch command, you can check if new memory has been allocated or not
