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

I got a RuntimeError, need help plz #29

Open
sfy-1739 opened this issue Mar 28, 2023 · 1 comment
Open

I got a RuntimeError, need help plz #29

sfy-1739 opened this issue Mar 28, 2023 · 1 comment

Comments

@sfy-1739
Copy link

My setting is torch: 1.10 cuda: 11.3

error:
Traceback (most recent call last): | 0/1856 [00:00<?, ?it/s]
File "train.py", line 211, in
main()
File "train.py", line 165, in main
train_model(
File "/home/sfy/PythonProject/VOTR/tools/train_utils/train_utils.py", line 91, in train_model
accumulated_iter = train_one_epoch(
File "/home/sfy/PythonProject/VOTR/tools/train_utils/train_utils.py", line 46, in train_one_epoch
loss.backward()
File "/home/sfy/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/_tensor.py", line 307, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File "/home/sfy/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/autograd/init.py", line 154, in backward
Variable._execution_engine.run_backward(
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [7944, 64]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

When add “torch.autograd.set_detect_anomaly(True)”, the error:

Traceback (most recent call last):
File "train.py", line 211, in
main()
File "train.py", line 165, in main
train_model(
File "/home/sfy/PythonProject/VOTR/tools/train_utils/train_utils.py", line 91, in train_model
accumulated_iter = train_one_epoch(
File "/home/sfy/PythonProject/VOTR/tools/train_utils/train_utils.py", line 46, in train_one_epoch
loss.backward()
File "/home/sfy/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/_tensor.py", line 307, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File "/home/sfy/anaconda3/envs/pytorch/lib/python3.8/site-packages/torch/autograd/init.py", line 154, in backward
Variable._execution_engine.run_backward(
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [5297, 64]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

How did you solve this problem?

Thank you!

@Alexmsit
Copy link

Hey @sfy-1739,

Any updates on this? Were you able to solve this issue?

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

2 participants