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

[core] On Linux try return not used memory to system on compile model destructor #27534

Conversation

praasz
Copy link
Contributor

@praasz praasz commented Nov 13, 2024

Details:

  • Optimize Linux process using OV memory consumption by returning not used memory to the system when compiled model is destroyed.
  • It should optimize memory usage by C++ and Python applications, as Linux avoid reclaim memory until process end especially for small chunks of allocations.

Tickets:

@praasz praasz requested a review from a team as a code owner November 13, 2024 12:39
@github-actions github-actions bot added the category: inference OpenVINO Runtime library - Inference label Nov 13, 2024
@praasz praasz added this to the 2025.0 milestone Nov 13, 2024
@ilya-lavrenov ilya-lavrenov self-assigned this Nov 13, 2024
@ilya-lavrenov ilya-lavrenov added this pull request to the merge queue Nov 13, 2024
@ilya-lavrenov
Copy link
Contributor

Do we need the same for other objects like ov::Model? or maybe even after some processes like compile / import model ?

Merged via the queue into openvinotoolkit:master with commit f417097 Nov 13, 2024
166 checks passed
@praasz
Copy link
Contributor Author

praasz commented Nov 14, 2024

Do we need the same for other objects like ov::Model? or maybe even after some processes like compile / import model ?

I've tried put in Model class but then is very easy to observe that execution time of loop: read, compile, infer, increased. The reason of that was that Model destructor were call many times an malloc_trim were called many times and also more system call for memory allocation occurred.
On Controlnet model from ticket the loop of 5 iterations the execution time changed from about 140s to 170s.

I would be very careful with using this function, maybe add in Core destructor is good point as it should not occur very often.
For compile / import if next actions will inference then is big chance that not used memory from these will be re-used by inference. After compile / import and some properties set the Core instance can be not required and its removal can trigger OS notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: inference OpenVINO Runtime library - Inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants