Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation #16

Open
CTDou opened this issue Apr 12, 2022 · 2 comments

Comments

@CTDou
Copy link

CTDou commented Apr 12, 2022

I try to run train.py,then error happen.Can anyone help?

Traceback (most recent call last):
File "D:\Program Files (x64)\PyCharm 2021.1.3\plugins\python\helpers\pydev\pydevd.py", line 1483, in exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\Program Files (x64)\PyCharm 2021.1.3\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "F:/20220410_BDRAR-master/train1.py", line 149, in
main()
File "F:/20220410_BDRAR-master/train1.py", line 78, in main
train(net, optimizer)
File "F:/20220410_BDRAR-master/train1.py", line 117, in train
loss.backward()
File "D:\anaconda3\envs\BDRAR\lib\site-packages\torch\tensor.py", line 245, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File "D:\anaconda3\envs\BDRAR\lib\site-packages\torch\autograd_init
.py", line 147, in backward
allow_unreachable=True, accumulate_grad=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 8, 128, 128]], which is output 0 of ReluBackward1, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
python-BaseException

@fromsamuel
Copy link

I have encountered the same issue, have you managed to find a solution in the meantime?

@wallrue
Copy link

wallrue commented Jun 19, 2022

This issue was solved at #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants