From 52458ae2736256d2ed5f4f6506a5b1789e03c425 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 18 Jan 2023 10:30:56 +0530 Subject: [PATCH] Revert "Don't set the specific vram optimizations to use, instead use the new sdkit API for setting the vram usage level directly" This reverts commit 42f9abdfe31e16160eb003a6da24449028f7e220. --- ui/easydiffusion/model_manager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/easydiffusion/model_manager.py b/ui/easydiffusion/model_manager.py index c0663463..7ed69a8c 100644 --- a/ui/easydiffusion/model_manager.py +++ b/ui/easydiffusion/model_manager.py @@ -24,6 +24,11 @@ DEFAULT_MODELS = { 'gfpgan': ['GFPGANv1.3'], 'realesrgan': ['RealESRGAN_x4plus'], } +VRAM_USAGE_LEVEL_TO_OPTIMIZATIONS = { + 'balanced': {'KEEP_FS_AND_CS_IN_CPU', 'SET_ATTENTION_STEP_TO_4'}, + 'low': {'KEEP_ENTIRE_MODEL_IN_CPU'}, + 'high': {}, +} MODELS_TO_LOAD_ON_START = ['stable-diffusion', 'vae', 'hypernetwork'] known_models = {} @@ -128,8 +133,10 @@ def set_vram_optimizations(context: Context): f'possible ({max_usage_level}) on this device ({context.device}). Using "{max_usage_level}" instead') vram_usage_level = max_usage_level - if vram_usage_level != context.vram_usage_level: - context.vram_usage_level = vram_usage_level + vram_optimizations = VRAM_USAGE_LEVEL_TO_OPTIMIZATIONS[vram_usage_level] + + if vram_optimizations != context.vram_optimizations: + context.vram_optimizations = vram_optimizations return True return False