Although remember that model.eval only has effect on dropout and batchnorm as we discussed, but still you need to use  torch.no_grad()  to loop over network for inference stage, otherwise, even if you have had set model.eval, gradients will be updated.

I see. But when would this be necessary? During training, it is customary to zero out the gradients with something like optimizer.zero_grad() before backpropagation, so that’s not an issue during training.
For pure inference with a pretrained model, do the gradients matter in any way? I guess keeping track of them might introduce a slight overhead.