Skip to content

Commit 7a16e8a

Browse files
Add --enable-dynamic-vram options to force enable it. (Comfy-Org#13002)
1 parent b202f84 commit 7a16e8a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

comfy/cli_args.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def from_string(cls, value: str):
149149
parser.add_argument("--async-offload", nargs='?', const=2, type=int, default=None, metavar="NUM_STREAMS", help="Use async weight offloading. An optional argument controls the amount of offload streams. Default is 2. Enabled by default on Nvidia.")
150150
parser.add_argument("--disable-async-offload", action="store_true", help="Disable async weight offloading.")
151151
parser.add_argument("--disable-dynamic-vram", action="store_true", help="Disable dynamic VRAM and use estimate based model loading.")
152+
parser.add_argument("--enable-dynamic-vram", action="store_true", help="Enable dynamic VRAM on systems where it's not enabled by default.")
152153

153154
parser.add_argument("--force-non-blocking", action="store_true", help="Force ComfyUI to use non-blocking operations for all applicable tensors. This may improve performance on some non-Nvidia systems but can cause issues with some workflows.")
154155

@@ -262,4 +263,6 @@ def is_valid_directory(path: str) -> str:
262263
args.fast = set(args.fast)
263264

264265
def enables_dynamic_vram():
266+
if args.enable_dynamic_vram:
267+
return True
265268
return not args.disable_dynamic_vram and not args.highvram and not args.gpu_only and not args.novram and not args.cpu

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ def execute_script(script_path):
206206
import comfy.memory_management
207207
import comfy.model_patcher
208208

209-
if enables_dynamic_vram() and comfy.model_management.is_nvidia() and not comfy.model_management.is_wsl():
210-
if comfy.model_management.torch_version_numeric < (2, 8):
209+
if args.enable_dynamic_vram or (enables_dynamic_vram() and comfy.model_management.is_nvidia() and not comfy.model_management.is_wsl()):
210+
if (not args.enable_dynamic_vram) and (comfy.model_management.torch_version_numeric < (2, 8)):
211211
logging.warning("Unsupported Pytorch detected. DynamicVRAM support requires Pytorch version 2.8 or later. Falling back to legacy ModelPatcher. VRAM estimates may be unreliable especially on Windows")
212212
elif comfy_aimdo.control.init_device(comfy.model_management.get_torch_device().index):
213213
if args.verbose == 'DEBUG':

0 commit comments

Comments
 (0)