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 leak in MacOS version #1075

Open
avijit-chakroborty opened this issue Nov 19, 2024 · 2 comments
Open

Memory leak in MacOS version #1075

avijit-chakroborty opened this issue Nov 19, 2024 · 2 comments
Assignees

Comments

@avijit-chakroborty
Copy link

Describe the bug
The memory consumption keeps growing when using the library.

To Reproduce
Steps to reproduce the behavior:

  1. Build the phi3 command line application from the examples/c/src directory
  2. Run phi3 in one terminal window
  3. On a separate terminal window, run the ps -p $(pgrep phi3) -o rss= command in a loop
  4. Now ask questions and watch the phi3 output.
  5. Simultaneously, in the second window observe that the memory usage grows over time with new questions asked.

Here's a small shell script that helps you to see the memory usage in 5 second intervals:

$ while true; do
while> mem_usage=$(ps -p $(pgrep phi3) -o rss=)
while> mem_usage_mb=$(echo "scale=2; $mem_usage/1024" | bc)
while> echo "Memory usage: $mem_usage_mb MB"
while> sleep 5
while> done

Observed memory usage:

Memory usage: 680.28 MB
Memory usage: 680.28 MB
Memory usage: 927.48 MB
Memory usage: 927.48 MB
Memory usage: 927.48 MB
Memory usage: 1019.68 MB
Memory usage: 1019.68 MB
Memory usage: 1019.68 MB
Memory usage: 1019.68 MB
Memory usage: 1019.68 MB
Memory usage: 1054.14 MB
Memory usage: 1056.70 MB
Memory usage: 1056.70 MB
Memory usage: 1061.62 MB
Memory usage: 1062.57 MB
Memory usage: 1127.75 MB
Memory usage: 1127.93 MB
Memory usage: 1128.82 MB
Memory usage: 1129.09 MB

The Android version of the same release doesn't show this behavior, just an FYI.

Expected behavior
Memory usage will stay within the certain bounds.

Desktop (please complete the following information):

  • OS: macOS Sequoia
  • Browser N/A
  • Version 15.1

Smartphone (please complete the following information):

  • N/A

Additional context
N/A

@skyline75489
Copy link
Contributor

Thanks for the report! I'll take a look.

@skyline75489
Copy link
Contributor

skyline75489 commented Nov 21, 2024

@avijit-chakroborty Are you using Phi-3-mini-4k-instruct-onnx? I'm seeing a memory usage capped at ~2.5GB on a M1 MacBook Pro 16GB.

Could you provide more information? For example the model of the device you're using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants