You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Denoising is the most computationally demanding process during diffusion. Methods that optimizes this process accelerates inference speed. Try the following methods for a speed up.
46
49
47
-
- Add `.to("cuda")` to place the pipeline on a GPU. Placing a model on an accelerator, like a GPU, increases speed because it performs computations in parallel.
50
+
- Add `device_map="cuda"` to place the pipeline on a GPU. Placing a model on an accelerator, like a GPU, increases speed because it performs computations in parallel.
48
51
- Set `torch_dtype=torch.bfloat16` to execute the pipeline in half-precision. Reducing the data type precision increases speed because it takes less time to perform computations in a lower precision.
49
52
50
53
```py
@@ -54,8 +57,9 @@ from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
54
57
55
58
pipeline = DiffusionPipeline.from_pretrained(
56
59
"stabilityai/stable-diffusion-xl-base-1.0",
57
-
torch_dtype=torch.bfloat16
58
-
).to("cuda")
60
+
torch_dtype=torch.bfloat16,
61
+
device_map="cuda
62
+
)
59
63
```
60
64
61
65
- Use a faster scheduler, such as [`DPMSolverMultistepScheduler`], which only requires ~20-25 steps.
@@ -88,8 +92,9 @@ Many modern diffusion models deliver high-quality images out-of-the-box. However
88
92
89
93
pipeline = DiffusionPipeline.from_pretrained(
90
94
"stabilityai/stable-diffusion-xl-base-1.0",
91
-
torch_dtype=torch.bfloat16
92
-
).to("cuda")
95
+
torch_dtype=torch.bfloat16,
96
+
device_map="cuda"
97
+
)
93
98
94
99
prompt ="""
95
100
cinematic film still of a cat sipping a margarita in a pool in Palm Springs, California
@@ -109,8 +114,9 @@ Many modern diffusion models deliver high-quality images out-of-the-box. However
0 commit comments