With torch.no_grad() - PyTorch Forums
https://discuss.pytorch.org/t/with-torch-no-grad/13014624.08.2021 · My model can finish its training phase, while validation phase will throw an exception: Runtime Error: CUDA out of memory. After using ‘with torch.no_grad()’, this model can works well, but I wonder why it’ll cause cuda out of memory without ‘with torch.no_grad()’ and what does ‘with torch.no_grad()’ change. My function is defined as follows: for i in …