encoder = nn.GRU(100, 100)
encoder.cuda()
hidden = Variable(torch.randn(1, 1, 100)).cuda()
output = ''
num = 0
while True:
output, hidden = encoder(hidden, hidden)
print num + 1
num +=1
The GPU memory usage keeps growing, and ends up in out of memory.