-
Notifications
You must be signed in to change notification settings - Fork 10
fix: release GPU tensors after prediction #144
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
Conversation
|
@mitchellxh thanks so much for your contribution!! Would you mind creating an issue that documents the problem you're seeing without this change? We can then link this PR to it. Depending on the nature of the problem, we might also want to add a test case. |
|
@mitchellxh many thanks for posting the issue! Is the probs = self.create_probabilities(img_features, txt_features)
probs = probs.detach().cpu() |
|
And for |
|
@hlapp the deletion step is not needed!
|
|
I've simplified the fix to what I understand is strictly necessary. @mitchellxh if you have time, could you check that the result should still be equivalent in outcome to your initial patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a GPU memory management issue by releasing GPU tensors after prediction to prevent VRAM accumulation during large batch processing.
- Adds explicit tensor detachment from GPU to CPU after probability computation
- Prevents GPU memory exhaustion when processing large image sets (~7k images)
- Includes explanatory comment for the memory management fix
hlapp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, thanks @mitchellxh for your contribution. I'll wait a bit for your 👍🏻 to my simplification before merging to ensure I haven't missed or misunderstood anything.
|
confirmed! VRAM remains stable with your simplified fix. |
Summary
Fixes #145.