Skip to content

Commit

Permalink
checks for GPU weights from Settings (#2019)
Browse files Browse the repository at this point in the history
for the case when GPU has changed and saved settings are not possible anymore
  • Loading branch information
DenOfEquity authored Oct 9, 2024
1 parent 7eb824a commit 82eb756
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules_forge/main_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 82eb756

Please sign in to comment.