I understand.
My problem is that I am deleting a lot of activation and other tensors after using them in my code and when their are not used any more but their memory also goes into the cache. I don’t want to use empty_cache() since as you said it will reallocate the memory needed for the model and slows down the code. But is there a way to avoid deleted tensor’s memory go into the cache?