-
Notifications
You must be signed in to change notification settings - Fork 6k
cpu_offload vRAM memory consumption large than 4GB #1934
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
Comments
Hey @Sanster, Thanks a lot for the super clean bug report. When running your code-snippet in combination with:
I can observe the same numbers as in your table. I think the problem is that we move all modules to GPU in the very beginning. We shouldn't do this. When setting: pipe.enable_sequential_cpu_offload() It's important to previously not run import torch
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16,
safety_checker=None,
)
prompt = "a photo of an astronaut riding a horse on mars"
pipe.enable_sequential_cpu_offload()
image = pipe(prompt, num_inference_steps=4).images[0] When running the above I'm getting <3GB memory usage. In this example here, I'm not using the It's an interesting use case here since by it might not be super intuitive to have to remove cc @pcuenca @patil-suraj @anton-l and maybe also @sgugger @muellerzr just FYI since it might be a common problem people run into. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Describe the bug
I am using the code from https://huggingface.co/docs/diffusers/optimization/fp16#offloading-to-cpu-with-accelerate-for-memory-savings to test
cpu_offload
, but the vRAM memory consumption is large than 4GBReproduction
I am using the code from https://huggingface.co/docs/diffusers/optimization/fp16#offloading-to-cpu-with-accelerate-for-memory-savings
Logs
No response
System Info
test on 1080/TITAN RTX
diffusers
version: 0.11.1accelerate
version: 0.15.0The text was updated successfully, but these errors were encountered: