If you’re trying to offload GPU memory to RAM perhaps you might want to have a look at torch.utils.checkpoint — PyTorch 1.8.0 documentation 3 . Although, it’s not exactly what you’re looking for, this might help reduce the amount of memory you need on the GPU!