mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-07-21 21:01:24 +08:00
reserve
This commit is contained in:
parent
b2bb5f97b5
commit
b295d4550b
@ -547,9 +547,19 @@ else:
|
||||
if total_vram > (15 * 1024):
|
||||
EXTRA_RESERVED_VRAM += 100 * 1024 * 1024
|
||||
|
||||
SETTING_RESERVED_VRAM = -1
|
||||
|
||||
|
||||
def set_reserved_memory(val: float):
|
||||
global SETTING_RESERVED_VRAM
|
||||
SETTING_RESERVED_VRAM = (1.0 - val) * total_vram * 1024 * 1024
|
||||
if SETTING_RESERVED_VRAM == 0.0:
|
||||
return
|
||||
logger.info("Manually Reserving {:0.0f} MB VRAM".format(SETTING_RESERVED_VRAM / (1024 * 1024)))
|
||||
|
||||
|
||||
def extra_reserved_memory() -> float:
|
||||
return EXTRA_RESERVED_VRAM
|
||||
return max(SETTING_RESERVED_VRAM, EXTRA_RESERVED_VRAM)
|
||||
|
||||
|
||||
def minimum_inference_memory() -> float:
|
||||
|
||||
@ -168,11 +168,19 @@ def configure_sigint_handler():
|
||||
signal.signal(signal.SIGINT, sigint_handler)
|
||||
|
||||
|
||||
def reserve_memory():
|
||||
from backend.memory_management import set_reserved_memory
|
||||
from modules.shared import opts
|
||||
|
||||
set_reserved_memory(opts.setting_allocated_vram)
|
||||
|
||||
|
||||
def configure_opts_onchange():
|
||||
from modules import shared, ui_tempdir
|
||||
|
||||
shared.opts.onchange("temp_dir", ui_tempdir.on_tmpdir_changed)
|
||||
shared.opts.onchange("gradio_theme", shared.reload_gradio_theme)
|
||||
shared.opts.onchange("setting_allocated_vram", reserve_memory)
|
||||
startup_timer.record("opts onchange")
|
||||
|
||||
|
||||
|
||||
@ -164,6 +164,7 @@ options_templates.update(
|
||||
options_section(
|
||||
("system", "System", "system"),
|
||||
{
|
||||
"setting_allocated_vram": OptionInfo(1.0, "GPU Weights", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}).info("amount of VRAM that Forge can access").info("in % of total vram"),
|
||||
"auto_launch_browser": OptionInfo("Local", "Launch the webui in browser on startup", gr.Radio, {"choices": ("Disable", "Local", "Remote")}).info("Remote = always automatically start; Local = only when not sharing the server, such as <b>--share</b>"),
|
||||
"enable_console_prompts": OptionInfo(False, "Print the generation prompts to console"),
|
||||
"samples_log_stdout": OptionInfo(False, "Print the generation infotxt to console"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user