Skip to content

Commit 9fe7b91

Browse files
committed
directly place on cuda.
1 parent 8510f98 commit 9fe7b91

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/diffusers/pipelines/flux/pipeline_flux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ def __call__(
777777

778778
# Offload all models
779779
self.maybe_free_model_hooks()
780-
780+
781781
if not return_dict:
782782
return (image,)
783783

tests/lora/test_lora_layers_flux.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def test_flux_the_last_ben(self):
202202
self.pipeline.load_lora_weights("TheLastBen/Jon_Snow_Flux_LoRA", weight_name="jon_snow.safetensors")
203203
self.pipeline.fuse_lora()
204204
self.pipeline.unload_lora_weights()
205-
self.pipeline.enable_model_cpu_offload()
205+
self.pipeline = self.pipeline.to("cuda")
206206

207207
prompt = "jon snow eating pizza with ketchup"
208208

@@ -225,7 +225,10 @@ def test_flux_kohya(self):
225225
self.pipeline.load_lora_weights("Norod78/brain-slug-flux")
226226
self.pipeline.fuse_lora()
227227
self.pipeline.unload_lora_weights()
228-
self.pipeline.enable_model_cpu_offload()
228+
# Instead of calling `enable_model_cpu_offload()`, we do a cuda placement here because the CI
229+
# run supports it. We have about 34GB RAM in the CI runner which kills the test when run with
230+
# `enable_model_cpu_offload()`.
231+
self.pipeline = self.pipeline.to("cuda")
229232

230233
prompt = "The cat with a brain slug earring"
231234
out = self.pipeline(
@@ -248,7 +251,7 @@ def test_flux_kohya_with_text_encoder(self):
248251
self.pipeline.load_lora_weights("cocktailpeanut/optimus", weight_name="optimus.safetensors")
249252
self.pipeline.fuse_lora()
250253
self.pipeline.unload_lora_weights()
251-
self.pipeline.enable_model_cpu_offload()
254+
self.pipeline = self.pipeline.to("cuda")
252255

253256
prompt = "optimus is cleaning the house with broomstick"
254257
out = self.pipeline(
@@ -271,7 +274,7 @@ def test_flux_xlabs(self):
271274
self.pipeline.load_lora_weights("XLabs-AI/flux-lora-collection", weight_name="disney_lora.safetensors")
272275
self.pipeline.fuse_lora()
273276
self.pipeline.unload_lora_weights()
274-
self.pipeline.enable_model_cpu_offload()
277+
self.pipeline = self.pipeline.to("cuda")
275278

276279
prompt = "A blue jay standing on a large basket of rainbow macarons, disney style"
277280

tests/lora/test_lora_layers_sd3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ def get_inputs(self, device, seed=0):
176176
def test_sd3_img2img_lora(self):
177177
pipe = self.pipeline_class.from_pretrained(self.repo_id, torch_dtype=torch.float16)
178178
pipe.load_lora_weights("nerijs/pixel-art-xl", weight_name="pixel-art-xl.safetensors")
179-
pipe.enable_sequential_cpu_offload()
179+
pipe.fuse_lora()
180+
pipe.unload_lora_weights()
181+
pipe = pipe.to("cuda")
180182

181183
inputs = self.get_inputs(torch_device)
182184

tests/pipelines/flux/test_pipeline_flux.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ def get_inputs(self, device, seed=0):
236236
def test_flux_inference(self):
237237
pipe = self.pipeline_class.from_pretrained(
238238
self.repo_id, torch_dtype=torch.bfloat16, text_encoder=None, text_encoder_2=None
239-
)
240-
pipe.enable_model_cpu_offload()
239+
).to("cuda")
241240

242241
inputs = self.get_inputs(torch_device)
243242

0 commit comments

Comments
 (0)