Skip to content

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 issue with regular torch version.

comfyanonymous2be27427116c
diff --git a/comfy/model_management.py b/comfy/model_management.py
index 3736b57a9..4c2441f4e 100644
--- a/comfy/model_management.py
+++ b/comfy/model_management.py
@@ -390,7 +390,11 @@ def unet_inital_load_device(parameters, dtype):
return torch_dev
cpu_dev = torch.device("cpu")
- model_size = dtype.itemsize * parameters
+ dtype_size = 4
+ if dtype == torch.float16 or dtype == torch.bfloat16:
+ dtype_size = 2
+
+ model_size = dtype_size * parameters
mem_dev = get_free_memory(torch_dev)
mem_cpu = get_free_memory(cpu_dev)