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

P2T replaces PVT trunk bug #5

Closed
liu-tianxiang opened this issue Sep 13, 2022 · 2 comments
Closed

P2T replaces PVT trunk bug #5

liu-tianxiang opened this issue Sep 13, 2022 · 2 comments

Comments

@liu-tianxiang
Copy link

When I replaced the PVT trunk with P2T in my code, I encountered an error :
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [16, 512, 3, 3]], which is output 0 of AdaptiveAvgPool2DBackward, 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).

@yuhuan-wu
Copy link
Owner

Thanks for you notice. In some higher torch versions, inplace operation after adaptive_avg_pool is not supported.

I have disabled the inplace operation in the newest version. See the right change here:

P2T/p2t.py

Line 74 in 4d52408

pool = pool + l(pool) # fix backward bug in higher torch versions when training

@liu-tianxiang
Copy link
Author

Thanks! problem solved

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