@zazzyy if you call detach_() then there is no node in the graph that requires_grad=True, so autograd is complaining that it has no work to do.
What you might want to do is (maybe), instead of x.detach_(), call x = Variable(x.data, requires_grad=True) (or some form of this, that will compute gradients).