Skip to content

Commit 4941671

Browse files
Fix cuda getting initialized in cpu mode. (Comfy-Org#12779)
1 parent c5fe8ac commit 4941671

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

comfy/model_management.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,12 +1666,16 @@ def lora_compute_dtype(device):
16661666
return dtype
16671667

16681668
def synchronize():
1669+
if cpu_mode():
1670+
return
16691671
if is_intel_xpu():
16701672
torch.xpu.synchronize()
16711673
elif torch.cuda.is_available():
16721674
torch.cuda.synchronize()
16731675

16741676
def soft_empty_cache(force=False):
1677+
if cpu_mode():
1678+
return
16751679
global cpu_state
16761680
if cpu_state == CPUState.MPS:
16771681
torch.mps.empty_cache()

0 commit comments

Comments
 (0)