Solved by albanD in post #2 
              
              
                Hi, 

You should actuall wrap the whole validation code (that requires no backward) within this torch.no_grad() block. Note that you can also use it as a decorator of your eval function:

@torch.no_grad()
def val(args):
    # You validation function
    return accuracy

1-bis In recent pytorch versi…