Hi Thomas,
Thanks a lot for you reply. I guess I might have not stated the problem clearly. My target is to free the memory of some large tensors manually in a function before these tensors are out of the function’s scope, in order to save the total memory usage and avoid “CUDA out of memory” error.
I have edited the problem description. Can you take a look again? Thanks!