Skip to content

Commit 5f9d5a2

Browse files
authored
Hotfix for the div zero occurrence when memory_used_encode is 0 (Comfy-Org#5121)
Comfy-Org#5069 (comment)
1 parent 14eba07 commit 5f9d5a2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

comfy/sd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def encode(self, pixel_samples):
347347
memory_used = self.memory_used_encode(pixel_samples.shape, self.vae_dtype)
348348
model_management.load_models_gpu([self.patcher], memory_required=memory_used)
349349
free_memory = model_management.get_free_memory(self.device)
350-
batch_number = int(free_memory / memory_used)
350+
batch_number = int(free_memory / max(1, memory_used))
351351
batch_number = max(1, batch_number)
352352
samples = torch.empty((pixel_samples.shape[0], self.latent_channels) + tuple(map(lambda a: a // self.downscale_ratio, pixel_samples.shape[2:])), device=self.output_device)
353353
for x in range(0, pixel_samples.shape[0], batch_number):

0 commit comments

Comments
 (0)