Inference in torch v0.4 blows up memory resources

In torch v0.3.*, I had something similar to what’s shown below, and it worked fine:

# x was originally a list of tensors
x = Variable(torch.cat(x), volatile=True)
y_pred = model(x)

After upgrading to v4.0, I changed the above lines with:

# this consumes all the memory, crashes the system and kills my soul
with torch.no_grad():
    # no longer require Variable
    x = torch.cat(x)
y_pred = model(x)

However, this totally blows up the system. The computer runs out of memory and crashes the code. What am I doing wrong?

By the way, I also tried putting the entire calculation of each tensor in the list x under with torch.no_grad() but to no avail.