If you already removed unwanted references to the Variables, empty_cache should definitely work

@SimonW Could you elaborate what do you mean by remove unwanted references? Do you mean explicitly deleting variables (del variable) or something else?
After every epoch I’m calling torch.cuda.empty_cache(), but nvidia-smi still shows an increase in GPU memory after every loop.
    for epoch in range(20):
        for batch in train_data.batches:
            inputs, targets = batch
            predictions = model(inputs)
            predictions = predictions.view(-1, model.vocab_size, model.batch_size)
            targets = targets.view(-1, model.batch_size)
            loss = loss_function(predictions, targets)
            model.zero_grad()
            model.init_hidden()
            loss.backward()
            optimizer.step()
        tester.test(model)
        tester.print_samples()
        torch.cuda.empty_cache()