From 82eb7566172934d2edefc536afe2499b9593999f Mon Sep 17 00:00:00 2001 From: DenOfEquity <166248528+DenOfEquity@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:10:06 +0100 Subject: [PATCH] checks for GPU weights from Settings (#2019) for the case when GPU has changed and saved settings are not possible anymore --- modules_forge/main_entry.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules_forge/main_entry.py b/modules_forge/main_entry.py index 2492fc534..e9ea61d55 100644 --- a/modules_forge/main_entry.py +++ b/modules_forge/main_entry.py @@ -329,13 +329,16 @@ def on_preset_change(preset=None): ] if shared.opts.forge_preset == 'xl': + model_mem = getattr(shared.opts, "xl_GPU_MB", total_vram - 1024) + if model_mem < 0 or model_mem > total_vram: + model_mem = total_vram - 1024 return [ gr.update(visible=True), # ui_vae gr.update(visible=False, value=1), # ui_clip_skip gr.update(visible=True, value='Automatic'), # ui_forge_unet_storage_dtype_options gr.update(visible=False, value='Queue'), # ui_forge_async_loading gr.update(visible=False, value='CPU'), # ui_forge_pin_shared_memory - gr.update(visible=True, value=getattr(shared.opts, "xl_GPU_MB", total_vram - 1024)), # ui_forge_inference_memory + gr.update(visible=True, value=model_mem), # ui_forge_inference_memory gr.update(value=getattr(shared.opts, "xl_t2i_width", 896)), # ui_txt2img_width gr.update(value=getattr(shared.opts, "xl_i2i_width", 1024)), # ui_img2img_width gr.update(value=getattr(shared.opts, "xl_t2i_height", 1152)), # ui_txt2img_height @@ -353,13 +356,16 @@ def on_preset_change(preset=None): ] if shared.opts.forge_preset == 'flux': + model_mem = getattr(shared.opts, "flux_GPU_MB", total_vram - 1024) + if model_mem < 0 or model_mem > total_vram: + model_mem = total_vram - 1024 return [ gr.update(visible=True), # ui_vae gr.update(visible=False, value=1), # ui_clip_skip gr.update(visible=True, value='Automatic'), # ui_forge_unet_storage_dtype_options gr.update(visible=True, value='Queue'), # ui_forge_async_loading gr.update(visible=True, value='CPU'), # ui_forge_pin_shared_memory - gr.update(visible=True, value=getattr(shared.opts, "flux_GPU_MB", total_vram - 1024)), # ui_forge_inference_memory + gr.update(visible=True, value=model_mem), # ui_forge_inference_memory gr.update(value=getattr(shared.opts, "flux_t2i_width", 896)), # ui_txt2img_width gr.update(value=getattr(shared.opts, "flux_i2i_width", 1024)), # ui_img2img_width gr.update(value=getattr(shared.opts, "flux_t2i_height", 1152)), # ui_txt2img_height