unload models before loading llm

This commit is contained in:
maybleMyers 2025-12-06 02:18:25 -08:00
parent 252585ccbb
commit 24b7f8be0e
2 changed files with 17 additions and 26 deletions

View File

@ -393,6 +393,22 @@ def expand_prompt_standalone(prompt: str, model_path: str, system_prompt: str =
torch.cuda.empty_cache()
log_step("Previous model unloaded", unload_start)
# Unload diffusion models from VRAM to make room for LLM
log_step("Unloading diffusion models from VRAM to make room for LLM...")
unload_diffusion_start = time.time()
try:
from backend import memory_management
memory_management.unload_all_models()
memory_management.soft_empty_cache(force=True)
gc.collect()
torch.cuda.empty_cache()
gpu_mem = get_gpu_memory()
if gpu_mem:
log_step(f" After diffusion unload: {gpu_mem}")
log_step("Diffusion models unloaded", unload_diffusion_start)
except Exception as e:
log_step(f" Warning: Could not unload diffusion models: {e}")
log_step(f"Loading LLM model: {model_path}")
load_start = time.time()

View File

@ -1,26 +1 @@
Create a detailed, photorealistic image of a realistic domestic cat actively installing RAM sticks into an open consumer-grade PC case with an extreme RAM configuration.
Cat Subject Requirements:
Fully realistic tabby cat - standard quadrupedal feline anatomy
Detailed fur textures with visible individual hairs and stripes
Cat positioned on desk, both front paws carefully gripping a single RAM stick, placing it into a slot
Focused, intent expression with ears slightly forward
Natural cat proportions, sitting upright to reach the motherboard
Computer & Hardware Requirements - CRITICAL:
EXTREME RAM CONFIGURATION: Motherboard with 32 RAM slots arranged in a massive extended row spanning the entire top edge of the motherboard
30 RGB RAM sticks already installed - creating a spectacular wall of illuminated memory modules in rainbow colors
Only 2 empty slots remaining, cat installing stick #30
The RAM sticks should be the visual focal point - an absurdly long row of colorful memory modules
Large NVIDIA RTX 6090 graphics card with triple-fan design and illuminated "6090" branding
Open mid-tower case with glass panel removed
AIO liquid cooler, RGB fans, clean cable management
Environment & Composition:
Clean desk with anti-static mat
RAM packaging boxes scattered nearby
Soft lighting with RGB glow illuminating cat's fur
Overall Style: Hyperrealistic photography, humorous tech enthusiast scene, emphasis on the ridiculous quantity of RAM sticks as the key visual element.
Examine the prompt expansion pipeline when using the z image tab of the gui launched with webui-user.bat. Currently we are getting the error in console.txt. The script needs to unload the models currently in vram before loading the llm for prompt expansion.