The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Disable pinned memory automatically on integrated GPUs (#16746)
rattus4d981c9b09db
diff --git a/comfy/model_management.py b/comfy/model_management.pyindex 4ea7cbae7..13b690bdb 100644--- a/comfy/model_management.py+++ b/comfy/model_management.py@@ -1624,7 +1624,16 @@ def get_disk_swap_total():logging.warning("Could not get amount of swap memory on system.")return total-if not args.disable_pinned_memory:+def is_integrated_gpu():+ device = get_torch_device()+ return device.type == "cuda" and bool(torch.cuda.get_device_properties(device).is_integrated)++DISABLE_PINNED_MEMORY = args.disable_pinned_memory+if not DISABLE_PINNED_MEMORY and is_integrated_gpu():+ # Integrated GPU VRAM is carved out of system RAM, so pinning host memory only takes RAM from the GPU.+ DISABLE_PINNED_MEMORY = True++if not DISABLE_PINNED_MEMORY:if is_nvidia() or is_amd():ram = get_total_memory(torch.device("cpu"))if WINDOWS:diff --git a/comfy/pinned_memory.py b/comfy/pinned_memory.pyindex b3057c620..76374d2d5 100644--- a/comfy/pinned_memory.py+++ b/comfy/pinned_memory.py@@ -7,8 +7,6 @@ import comfy_aimdo.host_bufferimport comfy_aimdo.torchimport torch-from comfy.cli_args import args-def _add_to_bucket(module, module_pin, buckets, size, priority):bucket = buckets.setdefault(size, [])entry = [-priority, 0, module]@@ -51,7 +49,7 @@ def get_pin(module, subset="weights"):pins = module.__dict__.get("_pins")module_pin = None if pins is None else pins.get(subset)pin = None if module_pin is None else module_pin.get("pin")- if pin is None or module_pin["registered"] or args.disable_pinned_memory:+ if pin is None or module_pin["registered"] or comfy.model_management.DISABLE_PINNED_MEMORY:return pin_, _, stack_split, pinned_size, *_ = module._pin_state[subset]@@ -70,7 +68,7 @@ def get_pin(module, subset="weights"):def pin_memory(module, subset="weights", size=None):pin_state = module._pin_state- if args.disable_pinned_memory:+ if comfy.model_management.DISABLE_PINNED_MEMORY:returnpin = get_pin(module, subset)