Detaching the output of your generator is fine, if you don’t need gradients in the generator but only in the discriminator.
Usually you get None gradients, if the computation graph was somehow detached, e.g. by calling .item(), numpy(), rewrapping a tensor as x = torch.tensor(x, requires_grad=True), etc.
Do you get any valid gradients in your discriminator? Could you check the requires_grad attributes of the parameters?



 ljj7975:

also does using GPU make any difference in computation graph? t seems to be fine on CPU.


It should not make a difference, so a reproducible code snippet would be good to have to debug it.