|
31 | 31 | from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel |
32 | 32 | from diffusers.utils import load_image |
33 | 33 | from diffusers.utils.testing_utils import ( |
| 34 | + backend_empty_cache, |
34 | 35 | enable_full_determinism, |
35 | 36 | numpy_cosine_similarity_distance, |
36 | | - require_big_gpu_with_torch_cuda, |
| 37 | + require_big_accelerator, |
37 | 38 | slow, |
38 | 39 | torch_device, |
39 | 40 | ) |
@@ -219,20 +220,20 @@ def test_xformers_attention_forwardGenerator_pass(self): |
219 | 220 |
|
220 | 221 |
|
221 | 222 | @slow |
222 | | -@require_big_gpu_with_torch_cuda |
| 223 | +@require_big_accelerator |
223 | 224 | @pytest.mark.big_gpu_with_torch_cuda |
224 | 225 | class StableDiffusion3ControlNetPipelineSlowTests(unittest.TestCase): |
225 | 226 | pipeline_class = StableDiffusion3ControlNetPipeline |
226 | 227 |
|
227 | 228 | def setUp(self): |
228 | 229 | super().setUp() |
229 | 230 | gc.collect() |
230 | | - torch.cuda.empty_cache() |
| 231 | + backend_empty_cache(torch_device) |
231 | 232 |
|
232 | 233 | def tearDown(self): |
233 | 234 | super().tearDown() |
234 | 235 | gc.collect() |
235 | | - torch.cuda.empty_cache() |
| 236 | + backend_empty_cache(torch_device) |
236 | 237 |
|
237 | 238 | def test_canny(self): |
238 | 239 | controlnet = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Canny", torch_dtype=torch.float16) |
@@ -272,7 +273,7 @@ def test_pose(self): |
272 | 273 | pipe = StableDiffusion3ControlNetPipeline.from_pretrained( |
273 | 274 | "stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet, torch_dtype=torch.float16 |
274 | 275 | ) |
275 | | - pipe.enable_model_cpu_offload() |
| 276 | + pipe.enable_model_cpu_offload(device=torch_device) |
276 | 277 | pipe.set_progress_bar_config(disable=None) |
277 | 278 |
|
278 | 279 | generator = torch.Generator(device="cpu").manual_seed(0) |
@@ -304,7 +305,7 @@ def test_tile(self): |
304 | 305 | pipe = StableDiffusion3ControlNetPipeline.from_pretrained( |
305 | 306 | "stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet, torch_dtype=torch.float16 |
306 | 307 | ) |
307 | | - pipe.enable_model_cpu_offload() |
| 308 | + pipe.enable_model_cpu_offload(device=torch_device) |
308 | 309 | pipe.set_progress_bar_config(disable=None) |
309 | 310 |
|
310 | 311 | generator = torch.Generator(device="cpu").manual_seed(0) |
@@ -338,7 +339,7 @@ def test_multi_controlnet(self): |
338 | 339 | pipe = StableDiffusion3ControlNetPipeline.from_pretrained( |
339 | 340 | "stabilityai/stable-diffusion-3-medium-diffusers", controlnet=controlnet, torch_dtype=torch.float16 |
340 | 341 | ) |
341 | | - pipe.enable_model_cpu_offload() |
| 342 | + pipe.enable_model_cpu_offload(device=torch_device) |
342 | 343 | pipe.set_progress_bar_config(disable=None) |
343 | 344 |
|
344 | 345 | generator = torch.Generator(device="cpu").manual_seed(0) |
|
0 commit comments