mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
Add IPEX Optimizers and use XPU instead of CPU when using IPEX
This commit is contained in:
+5
-1
@@ -111,7 +111,11 @@ def set_cuda_params():
|
||||
unet_needs_upcast = shared.opts.upcast_sampling
|
||||
|
||||
|
||||
cpu = torch.device("cpu")
|
||||
from launch import args
|
||||
if args.use_ipex:
|
||||
cpu = torch.device("xpu") #Use XPU instead of CPU. %20 Perf improvement on weak CPUs.
|
||||
else:
|
||||
cpu = torch.device("cpu")
|
||||
device = device_interrogate = device_gfpgan = device_esrgan = device_codeformer = None
|
||||
dtype = torch.float16
|
||||
dtype_vae = torch.float16
|
||||
|
||||
@@ -398,6 +398,9 @@ def load_model(checkpoint_info=None, already_loaded_state_dict=None, timer=None)
|
||||
sd_hijack.model_hijack.hijack(sd_model)
|
||||
timer.record("hijack")
|
||||
sd_model.eval()
|
||||
if shared.cmd_opts.use_ipex:
|
||||
sd_model = torch.xpu.optimize(sd_model, dtype=devices.dtype)
|
||||
shared.log.info("Applied IPEX Optimize")
|
||||
shared.sd_model = sd_model
|
||||
sd_hijack.model_hijack.embedding_db.load_textual_inversion_embeddings(force_reload=True) # Reload embeddings after model load as they may or may not fit the model
|
||||
timer.record("embeddings")
|
||||
|
||||
Reference in New Issue
Block a user