Hey!
Following this post 151, you would need to detach your tensor on the gpu so that it becomes a leaf node in the compute graph. Gradients can only be computed wrt. a leaf node in the graph.
Here 90 is the gist of the modified code. Hope it helps