mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 13:32:36 +08:00
Merge branch 'comfyanonymous:master' into fix/secure-combo
This commit is contained in:
commit
0be1d08c31
@ -216,6 +216,11 @@ current_gpu_controlnets = []
|
|||||||
|
|
||||||
model_accelerated = False
|
model_accelerated = False
|
||||||
|
|
||||||
|
def unet_offload_device():
|
||||||
|
if vram_state == VRAMState.HIGH_VRAM or vram_state == VRAMState.SHARED:
|
||||||
|
return get_torch_device()
|
||||||
|
else:
|
||||||
|
return torch.device("cpu")
|
||||||
|
|
||||||
def unload_model():
|
def unload_model():
|
||||||
global current_loaded_model
|
global current_loaded_model
|
||||||
@ -228,10 +233,9 @@ def unload_model():
|
|||||||
accelerate.hooks.remove_hook_from_submodules(current_loaded_model.model)
|
accelerate.hooks.remove_hook_from_submodules(current_loaded_model.model)
|
||||||
model_accelerated = False
|
model_accelerated = False
|
||||||
|
|
||||||
#never unload models from GPU on high vram
|
|
||||||
if vram_state != VRAMState.HIGH_VRAM:
|
current_loaded_model.model.to(unet_offload_device())
|
||||||
current_loaded_model.model.cpu()
|
current_loaded_model.model_patches_to(unet_offload_device())
|
||||||
current_loaded_model.model_patches_to("cpu")
|
|
||||||
current_loaded_model.unpatch_model()
|
current_loaded_model.unpatch_model()
|
||||||
current_loaded_model = None
|
current_loaded_model = None
|
||||||
|
|
||||||
|
|||||||
@ -1142,6 +1142,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
|
|||||||
clipvision = clip_vision.load_clipvision_from_sd(sd, model_config.clip_vision_prefix, True)
|
clipvision = clip_vision.load_clipvision_from_sd(sd, model_config.clip_vision_prefix, True)
|
||||||
|
|
||||||
model = model_config.get_model(sd)
|
model = model_config.get_model(sd)
|
||||||
|
model = model.to(model_management.unet_offload_device())
|
||||||
model.load_model_weights(sd, "model.diffusion_model.")
|
model.load_model_weights(sd, "model.diffusion_model.")
|
||||||
|
|
||||||
if output_vae:
|
if output_vae:
|
||||||
|
|||||||
@ -95,7 +95,7 @@ class SD1ClipModel(torch.nn.Module, ClipTokenWeightEncoder):
|
|||||||
out_tokens += [tokens_temp]
|
out_tokens += [tokens_temp]
|
||||||
|
|
||||||
if len(embedding_weights) > 0:
|
if len(embedding_weights) > 0:
|
||||||
new_embedding = torch.nn.Embedding(next_new_token, current_embeds.weight.shape[1])
|
new_embedding = torch.nn.Embedding(next_new_token, current_embeds.weight.shape[1], device=self.device)
|
||||||
new_embedding.weight[:token_dict_size] = current_embeds.weight[:]
|
new_embedding.weight[:token_dict_size] = current_embeds.weight[:]
|
||||||
n = token_dict_size
|
n = token_dict_size
|
||||||
for x in embedding_weights:
|
for x in embedding_weights:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user