File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -5404,7 +5404,7 @@ def sample_images_common(
5404
5404
clean_memory_on_device (accelerator .device )
5405
5405
5406
5406
torch .set_rng_state (rng_state )
5407
- if cuda_rng_state is not None :
5407
+ if torch . cuda . is_available () and cuda_rng_state is not None :
5408
5408
torch .cuda .set_rng_state (cuda_rng_state )
5409
5409
vae .to (org_vae_device )
5410
5410
@@ -5438,11 +5438,13 @@ def sample_image_inference(
5438
5438
5439
5439
if seed is not None :
5440
5440
torch .manual_seed (seed )
5441
- torch .cuda .manual_seed (seed )
5441
+ if torch .cuda .is_available ():
5442
+ torch .cuda .manual_seed (seed )
5442
5443
else :
5443
5444
# True random sample image generation
5444
5445
torch .seed ()
5445
- torch .cuda .seed ()
5446
+ if torch .cuda .is_available ():
5447
+ torch .cuda .seed ()
5446
5448
5447
5449
scheduler = get_my_scheduler (
5448
5450
sample_sampler = sampler_name ,
@@ -5477,8 +5479,9 @@ def sample_image_inference(
5477
5479
controlnet_image = controlnet_image ,
5478
5480
)
5479
5481
5480
- with torch .cuda .device (torch .cuda .current_device ()):
5481
- torch .cuda .empty_cache ()
5482
+ if torch .cuda .is_available ():
5483
+ with torch .cuda .device (torch .cuda .current_device ()):
5484
+ torch .cuda .empty_cache ()
5482
5485
5483
5486
image = pipeline .latents_to_image (latents )[0 ]
5484
5487
You can’t perform that action at this time.
0 commit comments