Skip to content

Commit

Permalink
Improvements for OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jul 3, 2023
1 parent 103c487 commit dc9d1f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions comfy/model_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,19 @@ def unload_if_low_vram(model):
return model

def unet_offload_device():
if vram_state == VRAMState.HIGH_VRAM or vram_state == VRAMState.SHARED:
if vram_state == VRAMState.HIGH_VRAM:
return get_torch_device()
else:
return torch.device("cpu")

def text_encoder_offload_device():
if args.gpu_only or vram_state == VRAMState.SHARED:
if args.gpu_only:
return get_torch_device()
else:
return torch.device("cpu")

def text_encoder_device():
if args.gpu_only or vram_state == VRAMState.SHARED:
if args.gpu_only:
return get_torch_device()
elif vram_state == VRAMState.HIGH_VRAM or vram_state == VRAMState.NORMAL_VRAM:
if torch.get_num_threads() < 8: #leaving the text encoder on the CPU is faster than shifting it if the CPU is fast enough.
Expand All @@ -360,7 +360,7 @@ def vae_device():
return get_torch_device()

def vae_offload_device():
if args.gpu_only or vram_state == VRAMState.SHARED:
if args.gpu_only:
return get_torch_device()
else:
return torch.device("cpu")
Expand Down

0 comments on commit dc9d1f3

Please sign in to comment.