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

Clearing cuda cache during interpolation is slow #236

Closed
AntoineTheb opened this issue May 1, 2024 · 1 comment · Fixed by #238
Closed

Clearing cuda cache during interpolation is slow #236

AntoineTheb opened this issue May 1, 2024 · 1 comment · Fixed by #238

Comments

@AntoineTheb
Copy link
Collaborator

Hi @EmmaRenauld !

I was profiling my training and noticed that "torch._C._cuda_emptyCache()" was slowing down my tracking process quite a lot.

image

Looking at dwi_ml.data.processing.volume.interpolation.interpolate_volume_in_neighborhood (https://github.com/scil-vital/dwi_ml/blob/master/dwi_ml/data/processing/volume/interpolation.py#L166), the comment does mention that it may be a bit low but saves on memory. Would it be possible to make clearing the cache optional ? Or leave it to the user ? Personally I never encountered memory leaks due to this.

Thanks !

@EmmaRenauld
Copy link
Collaborator

EmmaRenauld commented May 1, 2024

Ok, yes. Do a PR, and I will test it both locally and on Beluga, to see if my things still run correctly. I remember that I was not sure at all how to manage all this.
It's not really exactly memory leaks. It's just that there are variables that are deleted in the code but not yet in the memory.
But also, it could be very different in torch 2.0. Did you have time to see if you can install everything with it? I could merge PR 234 before we test the interpolation.

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

Successfully merging a pull request may close this issue.

2 participants