It seems you are storing the computation graph in this line: iter_loss += loss. Use iter_loss += loss.item().
Also add with torch.no_grad(): before the validation loop, as this will save some memory by avoiding storing variables necessary to calculate gradients.