Thanks for the reply, @jmaronas. How can I free the memory manually?
My main loop is as follow:
model.train()
hidden = None

for epoch in range(epochs):
  
  predictions = []
  true_values = []
  loss_avg = 0
  progress_bar = tqdm_notebook(dataloader)
  
  for i, (X,y) in enumerate(progress_bar):
    
    progress_bar.set_description('Epoch ' + str(epoch))
    
    X = X.to(device)
    y = y.to(device)
    
    loss, output, hidden = learn(X,y, hidden)
    
    
    loss_avg += loss
      
    predictions.append(output.item())
    true_values.append(y.item())