As @111137 suggested, I think that you should separate the two for loops. That could be something like:
for e in range(nb_epochs):
     model.train()
     for batch, (images, labels) in dataIterTrain:
           optimizer.zero_grad()
           do your stuff
    model.eval()
    with torch.no_grad(): 
     for batch, (images, labels) in dataIterVal:
          validate your model
          

And don’t forget that some modules have different behavior dependently of the mode of the model. So even at the end of the training loop, if you do something like:
model.train()
output_train = model(input)
model.eval()
output_eval = model(input)

The two output will be different.