I also had a similar problem. Although all the variables had require_grad = True, the gradients was None
After scrutinizing my code, I realized that in one of my modules, there was with torch.no_grad: in forward method that disabled the gradient computation. Therefore, I removed it and the problem was solved.