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

Inplace RunError when testing backward of RevNet with PyTorch 1.11.0 #102

Open
taokz opened this issue Aug 9, 2022 · 1 comment
Open

Comments

@taokz
Copy link

taokz commented Aug 9, 2022

Hi, thank you for your good code, recently I've tried to reproduce RevNet with PyTorch 1.11.0, and I use your code. However, I got a RunError as follows:

File ~\Documents\RevNet\revnet.py:71, in ReversibleBlockFunction.backward(ctx, grad_y)
     68 gm = ctx.gm
     70 with torch.autograd.set_detect_anomaly(True):
---> 71     x, y = ctx.saved_variables
     72 # x, y = ctx.saved_tensors
     73 y1, y2 = torch.chunk(y, chunks=2, dim=1)

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [0]], which is output 0 of ReversibleBlockFunctionBackward, is at version 3; expected version 2 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!

I've searched potential solution on the Internet but I still can not solve it. One solution is to downgrade the pytorch version to 1.4.0 but this version does not support the GPU I use. Could you provide some suggestions for me? I appreciate your help. Thanks!

@Unqua
Copy link

Unqua commented Nov 4, 2023

Hi, I addressed the issue by modifying line 94 to:
x = torch.cat((x1, x2), dim=1).data.contiguous()
and by removing line 124:
x.data.set_()
However, I'm not entirely certain about the ramifications of these changes.

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