try fix colab with virtual ram (#378)

try fix colab with virtual ram (#378)
This commit is contained in:
lllyasviel
2023-09-15 01:24:07 -07:00
committed by GitHub
parent b5b4fd27f1
commit cf7cde08b1
7 changed files with 248 additions and 28 deletions
+9 -4
View File
@@ -16,6 +16,7 @@ def worker():
import modules.default_pipeline as pipeline
import modules.path
import modules.patch
import modules.virtual_memory as virtual_memory
from modules.sdxl_styles import apply_style, aspect_ratios, fooocus_expansion
from modules.private_logger import log
@@ -80,10 +81,10 @@ def worker():
progressbar(3, 'Loading models ...')
pipeline.refresh_base_model(base_model_name)
pipeline.refresh_refiner_model(refiner_model_name)
pipeline.refresh_loras(loras)
pipeline.clear_all_caches()
pipeline.refresh_everything(
refiner_model_name=refiner_model_name,
base_model_name=base_model_name,
loras=loras)
progressbar(3, 'Processing prompts ...')
@@ -137,6 +138,8 @@ def worker():
pool_top_k=negative_top_k)
if pipeline.xl_refiner is not None:
virtual_memory.load_from_virtual_memory(pipeline.xl_refiner.clip.cond_stage_model)
for i, t in enumerate(tasks):
progressbar(11, f'Encoding refiner positive #{i + 1} ...')
t['c'][1] = pipeline.clip_encode(sd=pipeline.xl_refiner, texts=t['positive'],
@@ -147,6 +150,8 @@ def worker():
t['uc'][1] = pipeline.clip_encode(sd=pipeline.xl_refiner, texts=t['negative'],
pool_top_k=negative_top_k)
virtual_memory.try_move_to_virtual_memory(pipeline.xl_refiner.clip.cond_stage_model)
if performance_selction == 'Speed':
steps = 30
switch = 20