Instructions to use diffusers/controlnet-canny-sdxl-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use diffusers/controlnet-canny-sdxl-1.0 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("diffusers/controlnet-canny-sdxl-1.0", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
How do the example code utilize the GPU?
#16
by aliakyurek - opened
How do the example code utilize the GPU?
Because I don't see a code like pipe = pipe.to("cuda")
We use cpu offloading here so that the code can run on less than 10GB GPUs.
Different components will automatically loaded to GPU and offloaded from via the line:
pipe.enable_model_cpu_offload()
Therefore we don't need to do a .to("cuda") call.
For more information, you can check:
https://huggingface.co/docs/diffusers/v0.19.3/en/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline.enable_model_cpu_offload
Hope that this helps!
patrickvonplaten changed discussion status to closed