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

Manual release of memory #33

Closed
GunnarFarneback opened this issue Oct 18, 2023 · 1 comment · Fixed by #34
Closed

Manual release of memory #33

GunnarFarneback opened this issue Oct 18, 2023 · 1 comment · Fixed by #34

Comments

@GunnarFarneback
Copy link
Collaborator

ONNXRunTime objects release their memory through a finalizer, which calls the CAPI.release function. As noted in the docstring, garbage collection should normally handle this automatically. However if you have a large GPU model you might have extreme GPU memory pressure without any CPU memory pressure at all, and the garbage collection won't be in any hurry to destroy your objects, which would release your GPU memory.

Obviously CAPI.release gives you the tool to handle this manually but it's quite clunky both to dip down into the C API, and to separately extract the api and session fields for the release call.

My proposal is to add a highlevel release function/method for InferenceSession. Thoughts?

@jw3126
Copy link
Owner

jw3126 commented Oct 18, 2023

Yeah sounds like a useful addition. I think it should be a separate function from CAPI.release.

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