mirror of
https://github.com/vladmandic/automatic
synced 2026-09-17 16:24:33 +02:00
Fix --Xvram flags not activating offload
This commit is contained in:
@@ -294,7 +294,6 @@ def network_apply_weights(self: Union[torch.nn.Conv2d, torch.nn.Linear, torch.nn
|
||||
if network_layer_name is None:
|
||||
return
|
||||
t0 = time.time()
|
||||
weight = self.weight # calculate quant weights once
|
||||
current_names = getattr(self, "network_current_names", ())
|
||||
wanted_names = tuple((x.name, x.te_multiplier, x.unet_multiplier, x.dyn_dim) for x in loaded_networks)
|
||||
weights_backup = getattr(self, "network_weights_backup", None)
|
||||
@@ -304,7 +303,7 @@ def network_apply_weights(self: Union[torch.nn.Conv2d, torch.nn.Linear, torch.nn
|
||||
if isinstance(self, torch.nn.MultiheadAttention):
|
||||
weights_backup = (self.in_proj_weight.to(devices.cpu, copy=True), self.out_proj.weight.to(devices.cpu, copy=True))
|
||||
else:
|
||||
weights_backup = weight.to(devices.cpu, copy=True)
|
||||
weights_backup = self.weight.to(devices.cpu, copy=True)
|
||||
self.network_weights_backup = weights_backup
|
||||
bias_backup = getattr(self, "network_bias_backup", None)
|
||||
if bias_backup is None:
|
||||
@@ -324,6 +323,7 @@ def network_apply_weights(self: Union[torch.nn.Conv2d, torch.nn.Linear, torch.nn
|
||||
if module is not None and hasattr(self, 'weight'):
|
||||
try:
|
||||
with devices.inference_context():
|
||||
weight = self.weight # calculate quant weights once
|
||||
updown, ex_bias = module.calc_updown(weight)
|
||||
if len(weight.shape) == 4 and weight.shape[1] == 9:
|
||||
# inpainting model. zero pad updown to make channel[1] 4 to 9
|
||||
|
||||
@@ -1766,6 +1766,7 @@ def disable_offload(sd_model):
|
||||
if not isinstance(model, torch.nn.Module):
|
||||
continue
|
||||
remove_hook_from_module(model, recurse=True)
|
||||
sd_model.has_accelerate = False
|
||||
|
||||
|
||||
def unload_model_weights(op='model'):
|
||||
|
||||
@@ -374,6 +374,10 @@ if not (cmd_opts.lowvram or cmd_opts.medvram):
|
||||
else:
|
||||
offload_mode_default = "none"
|
||||
log.info(f"VRAM: Detected={gpu_memory} GB Optimization=none")
|
||||
elif cmd_opts.medvram:
|
||||
offload_mode_default = "cpu"
|
||||
elif cmd_opts.lowvram:
|
||||
offload_mode_default = "sequential"
|
||||
|
||||
|
||||
if devices.backend == "directml": # Force BMM for DirectML instead of SDP
|
||||
|
||||
Reference in New Issue
Block a user