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

Memory leakage during multiple loss calculations #483

Open
IzumiKDl opened this issue Feb 27, 2024 · 1 comment
Open

Memory leakage during multiple loss calculations #483

IzumiKDl opened this issue Feb 27, 2024 · 1 comment

Comments

@IzumiKDl
Copy link

Thank you for publishing this software package, it is very useful for the community. However, when I perform multiple loss calculations, the memory will continue to grow and will not be released in the end, resulting in the memory continuously increasing during the training process. When I restart a CAM object in a loop, even if the object is deleted at the end of the loop, memory accumulates. Have you ever thought about why this situation happened and how can I avoid it?
image

@jacobgil
Copy link
Owner

Hi,
We support a "with" clause that should solve this.
Can you please try, for example with:

    with GradCAM(model=model,
                       target_layers=target_layers) as cam:

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