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 #6

Open
qiaokang0 opened this issue May 31, 2018 · 11 comments

Comments

@qiaokang0
Copy link

qiaokang0 commented May 31, 2018

I try the code and get the runtime error down,any idea?

Training...
Epoch-0-: 0%| | 0/391 [00:00<?, ?it/s]Traceback (most recent call last):
File "main.py", line 46, in
main()
File "main.py", line 34, in main
trainer.train()
File "/home/qiaokang/MobileNet-V2-master/train.py", line 63, in train
cur_loss.backward()
File "/usr/local/lib/python3.5/dist-packages/torch/tensor.py", line 93, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/init.py", line 89, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

@ddhgiang
Copy link

ddhgiang commented Jun 4, 2018

also got the same problem

@nuptwuchen
Copy link

same problem

@MG2033
Copy link
Owner

MG2033 commented Jul 8, 2018

Which Pytorch version do you use?

@nekulkarni
Copy link

I got the same error with Pytorch 0.4.1.

Training...
Epoch-0-: 0%| | 0/391 [00:00<?, ?it/s]Traceback (most recent call last):
File "main.py", line 45, in
main()
File "main.py", line 33, in main
trainer.train()
File "/home/grafty/external_projects/pruning/MobileNet-V2/train.py", line 63, in train
cur_loss.backward()
File "/usr/local/lib/python3.5/dist-packages/torch/tensor.py", line 93, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/init.py", line 90, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

@nekulkarni
Copy link

Update: worked for me when I used pytorch 0.3.0. The error no longer came up.

@feixuedudiao
Copy link

what the checkpoint name,and where can download it?

@jehovahxu
Copy link

it worked when I used pytorch 0.3.1 but i was not found the change in pytorch 0.4.x

@lcj1105
Copy link

lcj1105 commented Sep 28, 2018

i also got the same problem in pyTorch 0.4.0

@jehovahxu
Copy link

jehovahxu commented Sep 28, 2018

i also got the same problem in pyTorch 0.4.0

changing your dropout or relu6 to out-of-place or use the model of https://github.com/tonylins/pytorch-mobilenet-v2

@lcj1105
Copy link

lcj1105 commented Sep 28, 2018

i also got the same problem in pyTorch 0.4.0

changing your dropout or relu6 to out-of-place or use the model of https://github.com/tonylins/pytorch-mobilenet-v2

thanks ! When I did this, the problem was solved.

@BlueBubbleWei
Copy link

search the keyword "inplace" in train.py and delete the args like inplace=True,or change inplace=False,I solved the problem,it's a pytorch version problem,the author used version 0.4,and yours in version 0.4.

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

9 participants