mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-25 15:55:18 +00:00
Some fixes to the lowvram system.
This commit is contained in:
parent
94323a26a7
commit
bc6be6c11e
@ -374,9 +374,14 @@ class ModelPatcher:
|
|||||||
loading = []
|
loading = []
|
||||||
for n, m in self.model.named_modules():
|
for n, m in self.model.named_modules():
|
||||||
params = []
|
params = []
|
||||||
|
skip = False
|
||||||
for name, param in m.named_parameters(recurse=False):
|
for name, param in m.named_parameters(recurse=False):
|
||||||
params.append(name)
|
params.append(name)
|
||||||
if hasattr(m, "comfy_cast_weights") or len(params) > 0:
|
for name, param in m.named_parameters(recurse=True):
|
||||||
|
if name not in params:
|
||||||
|
skip = True # skip random weights in non leaf modules
|
||||||
|
break
|
||||||
|
if not skip and (hasattr(m, "comfy_cast_weights") or len(params) > 0):
|
||||||
loading.append((comfy.model_management.module_size(m), n, m, params))
|
loading.append((comfy.model_management.module_size(m), n, m, params))
|
||||||
|
|
||||||
load_completely = []
|
load_completely = []
|
||||||
@ -420,8 +425,9 @@ class ModelPatcher:
|
|||||||
if m.comfy_cast_weights:
|
if m.comfy_cast_weights:
|
||||||
wipe_lowvram_weight(m)
|
wipe_lowvram_weight(m)
|
||||||
|
|
||||||
mem_counter += module_mem
|
if full_load or mem_counter + module_mem < lowvram_model_memory:
|
||||||
load_completely.append((module_mem, n, m, params))
|
mem_counter += module_mem
|
||||||
|
load_completely.append((module_mem, n, m, params))
|
||||||
|
|
||||||
load_completely.sort(reverse=True)
|
load_completely.sort(reverse=True)
|
||||||
for x in load_completely:
|
for x in load_completely:
|
||||||
|
Loading…
Reference in New Issue
Block a user