Skip to content

Commit

Permalink
Hotfix for the div zero occurrence when memory_used_encode is 0 (#5121)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltdrdata authored Oct 10, 2024
1 parent 14eba07 commit 5f9d5a2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion comfy/sd.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def encode(self, pixel_samples):
memory_used = self.memory_used_encode(pixel_samples.shape, self.vae_dtype)
model_management.load_models_gpu([self.patcher], memory_required=memory_used)
free_memory = model_management.get_free_memory(self.device)
batch_number = int(free_memory / memory_used)
batch_number = int(free_memory / max(1, memory_used))
batch_number = max(1, batch_number)
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)
for x in range(0, pixel_samples.shape[0], batch_number):
Expand Down

0 comments on commit 5f9d5a2

Please sign in to comment.