loss should already require gradients. Could you check its loss.grad_fn and make sure you see a valid function and not None?
If you are getting a None output, it seems that the computation graph was detached at some point and we would need to check your code.