Implementation-MolGAN-PyTorch
Implementation-MolGAN-PyTorch copied to clipboard
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation:
Thank you for your exciting work! But when I was running the GAN model, I encountered a problem.
————————————————————————
Start training...
[W python_anomaly_mode.cpp:104] Warning: Error detected in AddmmBackward. Traceback of forward call that caused the error:
File "main_gan.py", line 65, in
—————————————————————————————————— Can I ask how to solve it? Thank you very much.
Hello! @LiuJinzhe-Keepgoing I found a solution which atleast lets me train the network (haven't seen final results yet): In solver_gan.py around line 385 as your error suggest. Replace:
# Optimise generator.
if cur_step % self.n_critic == 0:
train_step_G.backward(retain_graph=True)
self.g_optimizer.step()
# Optimise value network.
if cur_step % self.n_critic == 0:
train_step_V.backward(retain_graph=True)
self.v_optimizer.step()
With the following:
if cur_step % self.n_critic == 0:
train_step_G.backward(retain_graph=True)
train_step_V.backward(retain_graph=True)
self.g_optimizer.step()
self.v_optimizer.step()
(Sorry for bad formatting this is the first time i respond to an issue). Hope this might help!
Solution found in the following thread: https://discuss.pytorch.org/t/solved-pytorch1-5-runtimeerror-one-of-the-variables-needed-for-gradient-computation-has-been-modified-by-an-inplace-operation/90256/34
Thank you, my good brother, joelhil. You have successfully solved my confusion. Thank you very much for the work you and your team have done. Best wishes and respect to you.