Skip to content

Commit

Permalink
Merge branch 'vae-fallback-cpu' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
jn-jairo committed Nov 11, 2023
2 parents 69dc0b6 + d47c58a commit aaaa9f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion comfy/sd.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,10 @@ def encode(self, pixel_samples):
if hasattr(self.device, 'type') and (self.device.type != 'cpu' and self.device.type != 'mps'):
devices.append(torch.device("cpu"))

pixel_samples = pixel_samples.clone().movedim(-1,1)

for device in devices:
self.first_stage_model = self.first_stage_model.to(device)
pixel_samples = pixel_samples.movedim(-1,1)
try:
memory_used = (2078 * pixel_samples.shape[2] * pixel_samples.shape[3]) * 1.7 #NOTE: this constant along with the one in the decode above are estimated from the mem usage for the VAE and could change.
model_management.free_memory(memory_used, device)
Expand Down

0 comments on commit aaaa9f1

Please sign in to comment.