You have to separate the two graphs(G and D) using detach. At the moment, network G also gets updated when calling d.update(d_loss). That’s why you are getting this error. You can see how it’s implemented in here:
https://github.com/pytorch/examples/blob/e0d33a69bec3eb4096c265451dbb85975eb961ea/dcgan/main.py#L225-L251 468