Solved by albanD in post #2 
              
              
                Hi, 
When you use .detach(), you break the graph and so gradients cannot be computed anymore. 
But the root issue is that for the autograd to work, the autograd engine needs to be able to know how to compute the gradient for each operation that is done. 
Unfortunately, if you don’t use pytorch ops, …