Solved by ptrblck in post #2 
              
              
                model.eval() changes the behavior of some layers, e.g. nn.Dropout won’t drop anymore and nn.BatchNorm will use the running estimates instead of the batch stats. 
To save some memory you should wrap your code in with torch.no_grad(): so that the intermediate activations won’t be stored: 
with torch.n…