Solved by albanD in post #2 
              
              
                Hi, 
A few things: 


Variable is not needed anymore, you can have simply images = data.to('cuda:0')

You are missing the optimizer.zero_grad() before the backward ! You need to manually reset the weights to 0 when you pytorch (see discussion about this here: Why do we need to set the gradients manu…