Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix meta tensor issue #29

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions scripts/model_mixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,22 @@ def change_mode(mode):
read_model_a_metadata = gr.Button("model A metadata")
read_model_b_metadata = gr.Button("model B metadata")

with gr.Row(variant="compact"):
unload_sd_model = gr.Button("Unload model to free VRAM")
reload_sd_model = gr.Button("Reload model back to VRAM")

unload_sd_model.click(
fn=sd_models.unload_model_weights,
inputs=[],
outputs=[]
)

reload_sd_model.click(
fn=sd_models.reload_model_weights,
inputs=[],
outputs=[]
)

def addblockweights(val, blockopt, *blocks):
if val == "none":
val = 0
Expand Down Expand Up @@ -2122,6 +2138,12 @@ def fake_checkpoint(checkpoint_info, metadata, model_name, sha256):
print("WARN: lowvram/medvram load_model() with minor workaround")
sd_models.unload_model_weights()
#sd_models.model_data.__init__()

if sd_models.model_data.sd_model:
sd_models.send_model_to_cpu(sd_models.model_data.sd_model)
sd_models.model_data.sd_model = None
devices.torch_gc()

sd_models.load_model(checkpoint_info=checkpoint_info, already_loaded_state_dict=state_dict)
del state_dict
devices.torch_gc()
Expand Down