the backtrace further above shows the operation that failed to compute its gradient
AlexAuthor7 opened this issue · 3 comments
AlexAuthor7 commented
The following error occurs while running linsat.py file
LinSAT forward time: 0.0345
Traceback (most recent call last):
File "linsat.py", line 281, in <module>
loss.backward()
File "/root/miniconda3/envs/torch2/lib/python3.8/site-packages/torch/_tensor.py", line 487, in backward
torch.autograd.backward(
File "/root/miniconda3/envs/torch2/lib/python3.8/site-packages/torch/autograd/__init__.py", line 200, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [1, 9]], which is output 0 of ExpBackward0, 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).
After adding torch.autograd.set_detect_anomaly(True) to the beginning of the code as prompted, the following error occurs
LinSAT forward time: 0.1173
/root/miniconda3/envs/torch2/lib/python3.8/site-packages/torch/autograd/__init__.py:200: UserWarning: Error detected in ExpBackward0. Traceback of forward call that caused the error:
File "linsat.py", line 277, in <module>
linsat_outp = linsat_layer(w, E=E, f=f, tau=0.1, max_iter=10, dummy_val=0)
File "linsat.py", line 98, in linsat_layer
x = kernel(x, A, b, tau, max_iter, dummy_val,
File "linsat.py", line 174, in linsat_kernel_v1
return torch.exp(log_x)
(Triggered internally at /opt/conda/conda-bld/pytorch_1678402421473/work/torch/csrc/autograd/python_anomaly_mode.cpp:114.)
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
Traceback (most recent call last):
File "linsat.py", line 281, in <module>
loss.backward()
File "/root/miniconda3/envs/torch2/lib/python3.8/site-packages/torch/_tensor.py", line 487, in backward
torch.autograd.backward(
File "/root/miniconda3/envs/torch2/lib/python3.8/site-packages/torch/autograd/__init__.py", line 200, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [1, 9]], which is output 0 of ExpBackward0, 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!
rogerwwww commented
Hi, sorry for the late reply. Can you offer a minimal example of your code to reproduce this issue?
rogerwwww commented
Now it shall be fixed by b8f9833. Please try again by upgrading pip install -U linsatnet
rogerwwww commented
I am closing this issue because it is no longer active. Please feel free to reopen it if you still face the error