Solved by albanD in post #2 
              
              
                Hi, 
For this to work you need to pass the create_graph=True option to the first .backward() to let it know that you need to be able to call .backward() on the grad itself. 
Also if you need the gradient wrt a specific variable, you can use the autograd.grad(outputs, inputs) function to get the deri…