-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Reduce Stable Diffusion memory usage by keeping unet only on GPU. #540
Comments
The linked PR is now closed:
But there might be a less intrusive way to keep the pipeline balanced between CPU and GPU (maybe using an |
@anton-l what if we:
To make it with no intrusion? This could work for all the multiple pipelines with little code changes too. Would something in that sense work? If yes, I can try opening a PR. |
I've created a feature request on |
Hey @piEsposito, I'm wondering whether we could maybe try to just write a community pipeline for this: https://github.com/huggingface/diffusers/tree/main/examples/community |
@patrickvonplaten I can do that and write the context for moving models between devices within the pipeline. That way we don't get blocked by the issue on How does that sound? |
Sounds great! |
Closed by #850 |
Is your feature request related to a problem? Please describe.
Stable Diffusion is not compute heavy on all its steps. If we keep the diffusion unet on fp16 on GPU and everything else on CPU, we could reduce the GPU usage to 2.2GB while having a non-so-big impact on performance. It should democratize Stable Diffusion even further.
Only other thing that would need to be done is move the tensors from the devices accordingly, but we can use the models
device
anddtype
attributes to make everything work.Describe the solution you'd like
I think what I'm proposing on #537 should be enough.
Describe alternatives you've considered
Alternative is to use GPUs for the whole process and pay more for it.
The text was updated successfully, but these errors were encountered: