Hi,
I changed my code as suggested but my GPU memory still doubles during evaluation. Wrapping my evaluation code in with torch.no_grad() helped the code run as I am no longer getting CUDA out of memory errors but my GPU memory still doubles
Before reading your post my code was structured like:
for i in range(50):
    for idx, (inputs, targets) in enumerate(loaders):
        inputs, targets = inputs.to(device), targets.to(device)
        optimizer.zero_grad()

        outputs = model(inputs)

        loss = loss_criterion(outputs, targets)

        predicted_output = torch.argmax(outputs.detach(), 0).squeeze(0)


        error_ = error(predicted_output.data.cpu(), targets.data.cpu().long().squeeze())

        running_loss.update(loss.item(), inputs.size(0))
        running_error.update(error_.item(), inputs.size(0))

But after your suggestion I changed it to:
def forward_pass(model_, input_, target_, loss_):
    outputs = model_(input_)

    loss = loss_(outputs, target_)

    predicted_output = torch.argmax(outputs.detach(), 0).squeeze(0)

    return loss, predicted_output

for i in range(50):
    for idx, (inputs, targets) in enumerate(loaders):
        inputs, targets = inputs.to(device), targets.to(device)
        optimizer.zero_grad()

        loss, predicted_output = forward_pass(model, inputs, targets, loss_criterion)

        error_ = error(predicted_output.data.cpu(), targets.data.cpu().long().squeeze())

        running_loss.update(loss.item(), inputs.size(0))
        running_error.update(error_.item(), inputs.size(0))

this made no difference on memory usage.
Thanks