Gpu memory gets filled

i have memory blow out error for this model this is a one layer lSTM with 200 nodes fills an 8gb gpu, batch size = 1,
in the next steps i convet the cost cost as cost.data.numpy() and accumilatet the value over batches

def train_model(batch):
opt.zero_grad()
#batch=next(gen)
input=Variable(torch.from_numpy(batch[1]),requires_grad=True).cuda()
target=Variable(torch.IntTensor(batch[0]))
input_length=Variable(torch.IntTensor(batch[2]))
target_length=Variable(torch.IntTensor(batch[3]))
output=model(input)
#…
output=output.unsqueeze(1)
#-------------------------------------
cost = ctc_loss(output, target.squeeze(0), input_length.squeeze(0), target_length.squeeze(0))
cost.backward()
opt.step()
#for param in model.parameters():
#print torch.norm(param)
return cost