I cannot see any obvious issues in the posted code snippet. However, it also doesn’t show the overall usage. In the cache method you are appending device tensors to the dequeu and see an increase in memory. Are you removing these objects properly from self.memory and are not storing any other references to these tensors?