I understand that requires_grad=True means history is traced, but even a repeated addition of a 5x3 tensor crashes python, as it runs out of memory. The code inside the loop represents an integration of the differential equation dx/dt=x. I’m using Pytorch 0.3.0 on Windows 10.
import torch
from torch.autograd import Variable

x = Variable(torch.FloatTensor(range(9)).view(3,3), requires_grad=True) 
time_step = 0.002
for i in range(10000):
    x = x + x*time_step    
y = torch.sum(x)  # just an arbitrary loss function (in fact none of the code from this line on is needed to recrate the crash)
y.backward()
print(x.grad)  

I do understand the advice laid out here 8 but you can easily imagine the need for code that looks like above for systems of ODEs.
How to handle this? Is truncation the only way?