The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix OSX latent2rgb previews.
comfyanonymous6c23854f54ed
diff --git a/comfy/model_management.py b/comfy/model_management.pyindex fbfbb7e4c..ef36a2c48 100644--- a/comfy/model_management.py+++ b/comfy/model_management.py@@ -630,8 +630,14 @@ def supports_dtype(device, dtype): #TODOdef device_supports_non_blocking(device):if is_device_mps(device):return False #pytorch bug? mps doesn't support non blocking+ return True++def device_should_use_non_blocking(device):+ if not device_supports_non_blocking(device):+ return Falsereturn False- # return True #TODO: figure out why this causes issues+ # return True #TODO: figure out why this causes memory issues on Nvidia and possibly others+def cast_to_device(tensor, device, dtype, copy=False):device_supports_cast = False@@ -643,7 +649,7 @@ def cast_to_device(tensor, device, dtype, copy=False):elif is_intel_xpu():device_supports_cast = True- non_blocking = device_supports_non_blocking(device)+ non_blocking = device_should_use_non_blocking(device)if device_supports_cast:if copy:diff --git a/comfy/ops.py b/comfy/ops.pyindex eb6507682..7ebb3dd2f 100644--- a/comfy/ops.py+++ b/comfy/ops.py@@ -21,7 +21,7 @@ import comfy.model_managementdef cast_bias_weight(s, input):bias = None- non_blocking = comfy.model_management.device_supports_non_blocking(input.device)+ non_blocking = comfy.model_management.device_should_use_non_blocking(input.device)if s.bias is not None:bias = s.bias.to(device=input.device, dtype=input.dtype, non_blocking=non_blocking)if s.bias_function is not None:diff --git a/latent_preview.py b/latent_preview.pyindex 05d750e2c..dae9beb60 100644--- a/latent_preview.py+++ b/latent_preview.py@@ -4,6 +4,7 @@ import structimport numpy as npfrom comfy.cli_args import args, LatentPreviewMethodfrom comfy.taesd.taesd import TAESD+import comfy.model_managementimport folder_pathsimport comfy.utilsimport logging@@ -43,7 +44,7 @@ class Latent2RGBPreviewer(LatentPreviewer):latents_ubyte = (((latent_image + 1) / 2).clamp(0, 1) # change scale from -1..1 to 0..1.mul(0xFF) # to 0..255- ).to(device="cpu", dtype=torch.uint8, non_blocking=True)+ ).to(device="cpu", dtype=torch.uint8, non_blocking=comfy.model_management.device_supports_non_blocking(latent_image.device))return Image.fromarray(latents_ubyte.numpy())