From 5edf481c8d87c770ca5596e87f5b51ba696da450 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Thu, 28 Sep 2023 14:38:22 +0300 Subject: [PATCH] Add Torch GC threshold slider --- modules/devices.py | 2 +- modules/shared.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/devices.py b/modules/devices.py index c84d2d397..797807edc 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -116,7 +116,7 @@ def torch_gc(force=False): if oom > previous_oom: previous_oom = oom log.warning(f'GPU out-of-memory error: {mem}') - if used > 90: + if used > shared.opts.torch_gc_threshold: log.info(f'GPU high memory utilization: {used}% {mem}') force = True if not force: diff --git a/modules/shared.py b/modules/shared.py index 9ce5d7db3..0b0954a1f 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -415,6 +415,7 @@ options_templates.update(options_section(('cuda', "Compute Settings"), { "cudnn_benchmark": OptionInfo(False, "Enable full-depth cuDNN benchmark feature"), "ipex_optimize": OptionInfo(True if devices.backend == "ipex" else False, "Enable IPEX Optimize for Intel GPUs"), "directml_memory_provider": OptionInfo(default_memory_provider, 'DirectML memory stats provider', gr.Radio, lambda: {"choices": memory_providers}), + "torch_gc_threshold": OptionInfo(90, "VRAM usage threshold before running Torch GC to clear up VRAM", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}), "cuda_compile_sep": OptionInfo("

Model Compile

", "", gr.HTML), "cuda_compile": OptionInfo(True if cmd_opts.use_openvino else False, "Enable model compile"), "cuda_compile_backend": OptionInfo("openvino_fx" if cmd_opts.use_openvino else "none", "Model compile backend", gr.Radio, lambda: {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex', 'openvino_fx']}),