alexandrosstergiou / SoftPool

[ICCV 2021] Code for approximated exponential maximum pooling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pytorch inplace operation issue

git-luo66 opened this issue · comments

hello
This is my mistake!
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 256, 40, 40]], 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).

The error ends here!
grad_input = torch.zeros_like(ctx.saved_tensors[0])
May I ask what caused the problem
thank you!

Hi @git-luo66 ,

Judging from the line of code you have highlighted, you are using the CUDA implementation of the code and not the inplace version. Assuming this, the error relates to an operation that happens after SoftPool. I would suggest to check that you are not using Relu with inplace=True. Another easy solution is to create a deep copy of the input before/after applying SoftPool.