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

Release GPU process memory after leaving for SD 1.5 and SD Turbo #62

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

ibelem
Copy link
Contributor

@ibelem ibelem commented Nov 15, 2024

Fix #61

  1. Add a "Release memory after leaving" switch in demo pages of SD 1.5 and SD Turbo, enabled by default
  2. Run session.release() for browser beforeunload event

When go to new page in same tab with "Release memory after leaving" switch disabled

  1. The memories of GPU process and blink (Tab) process are still high
  2. When click browser "Back" button, users can run "generate image" directly without loading models and compiling models

When go to new page in same tab with "Release memory after leaving" switch enabled

  1. The memory of GPU process will be released
  2. The memory of blink (Tab) process is still high
  3. When click browser "Back" button, users need to re-load and compile models then generate images

Note

It seems like the ONNX Runtime Web cannot release memory of blink (Tab) process.

@fs-eire WebAssembly memory cannot shrink. This means the wasm memory will keep the size of the peak memory usage, even if the code marks some part as "free".

@fdwr PTAL

CC @Honry @mingmingtasd @huningxin

Copy link
Collaborator

@fdwr fdwr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting - didn't know this memory was held. The $ change adds a bunch of noise that would be nicer as a separate CR (or at least separate commit), but the actual change looks fine to me, assuming my one concern is reassured.

@fdwr fdwr merged commit b807f8e into microsoft:main Nov 18, 2024
1 check passed
@ibelem
Copy link
Contributor Author

ibelem commented Nov 18, 2024

In the process of improving the memory code, I found that getElementById() and querySelector() were mixed used, and I couldn't help but change these codes. Will keep in mind the guidance of separating code formatting, refactoring, etc. from the original PR. :) @fdwr

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 this pull request may close these issues.

Memory is not released after leaving page for SD 1.5 and SD Turbo
2 participants