This commit is contained in:
lvmin 2023-10-13 04:53:02 -07:00
parent c4118d2418
commit 10e2db67d6
2 changed files with 14 additions and 6 deletions

View File

@ -482,12 +482,6 @@ def worker():
print(f'Preparation time: {preparation_time:.2f} seconds') print(f'Preparation time: {preparation_time:.2f} seconds')
outputs.append(['preview', (13, 'Moving model to GPU ...', None)]) outputs.append(['preview', (13, 'Moving model to GPU ...', None)])
execution_start_time = time.perf_counter()
fcbh.model_management.load_models_gpu([pipeline.final_unet])
moving_time = time.perf_counter() - execution_start_time
print(f'Moving model to GPU: {moving_time:.2f} seconds')
outputs.append(['preview', (13, 'Starting tasks ...', None)])
def callback(step, x0, x, total_steps, y): def callback(step, x0, x, total_steps, y):
done_steps = current_task_id * steps + step done_steps = current_task_id * steps + step

View File

@ -1,4 +1,5 @@
import torch import torch
import time
import fcbh.model_base import fcbh.model_base
import fcbh.ldm.modules.diffusionmodules.openaimodel import fcbh.ldm.modules.diffusionmodules.openaimodel
import fcbh.samplers import fcbh.samplers
@ -469,6 +470,15 @@ def patched_get_autocast_device(dev):
return 'cpu' return 'cpu'
def patched_load_models_gpu(*args, **kwargs):
execution_start_time = time.perf_counter()
y = fcbh.model_management.load_models_gpu_origin(*args, **kwargs)
moving_time = time.perf_counter() - execution_start_time
if moving_time > 0.1:
print(f'[Fooocus Model Management] Moving model(s) has taken {moving_time:.2f} seconds')
return y
def patch_all(): def patch_all():
if not fcbh.model_management.DISABLE_SMART_MEMORY: if not fcbh.model_management.DISABLE_SMART_MEMORY:
vram_inadequate = fcbh.model_management.total_vram < 20 * 1024 vram_inadequate = fcbh.model_management.total_vram < 20 * 1024
@ -481,6 +491,10 @@ def patch_all():
args_manager.args.disable_smart_memory = True args_manager.args.disable_smart_memory = True
fcbh.cli_args.args.disable_smart_memory = True fcbh.cli_args.args.disable_smart_memory = True
if not hasattr(fcbh.model_management, 'load_models_gpu_origin'):
fcbh.model_management.load_models_gpu_origin = fcbh.model_management.load_models_gpu
fcbh.model_management.load_models_gpu = patched_load_models_gpu
fcbh.model_management.get_autocast_device = patched_get_autocast_device fcbh.model_management.get_autocast_device = patched_get_autocast_device
fcbh.samplers.SAMPLER_NAMES += ['dpmpp_fooocus_2m_sde_inpaint_seamless'] fcbh.samplers.SAMPLER_NAMES += ['dpmpp_fooocus_2m_sde_inpaint_seamless']
fcbh.model_management.text_encoder_device = text_encoder_device_patched fcbh.model_management.text_encoder_device = text_encoder_device_patched