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("