If I’m not mistaken, there is no functionality in PyTorch, as the memory will be dynamically allocated and cached.
As an untested hack, you could try to allocate a huge tensor at the beginning of your script and delete it right after its creation. This should trigger PyTorch to allocate the memory block and put it into the cache without freeing it.