Asked about PyTorch in practice

Why wrap validation in torch.no_grad()?

An answer that works

It stops the framework recording operations for gradient computation, which is unnecessary during evaluation. It saves memory and time, and without it a large validation pass can run out of memory.

Reading an answer is not being able to give one. The section that teaches this is PyTorch in practice, 6 hours of PyTorch.

Learn this properly