mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
add manual module move for video models
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
from modules import shared, sd_models, timer, errors
|
||||
from modules import shared, sd_models, timer, errors, devices
|
||||
|
||||
|
||||
debug = shared.log.trace if os.environ.get('SD_VIDEO_DEBUG', None) is not None else lambda *args, **kwargs: None
|
||||
@@ -31,6 +31,7 @@ def set_prompt(p):
|
||||
def hijack_encode_prompt(*args, **kwargs):
|
||||
t0 = time.time()
|
||||
try:
|
||||
sd_models.move_model(shared.sd_model.text_encoder, devices.device)
|
||||
res = shared.sd_model.orig_encode_prompt(*args, **kwargs)
|
||||
except Exception as e:
|
||||
shared.log.error(f'Video encode: {e}')
|
||||
|
||||
@@ -57,6 +57,7 @@ def hijack_vae_decode(*args, **kwargs):
|
||||
if res is None:
|
||||
shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model, exclude=['vae'])
|
||||
try:
|
||||
sd_models.move_model(shared.sd_model.vae, devices.device)
|
||||
if torch.is_tensor(args[0]):
|
||||
latent = args[0]
|
||||
latent = latent.to(device=devices.device, dtype=shared.sd_model.vae.dtype) # upcast to vae dtype
|
||||
|
||||
Reference in New Issue
Block a user