Your use of torch.no_grad() looks fine to me. model.eval should be set just before you enter the validation (or evaluation loop). Set the mode back to model.train once you exit that loop. Similarly, ensure whenever you’re performing evaluation of any kind, mode is set to eval.
The reason is nicely discussed here 10.