Merge pull request #774 from lansing/lansing/sdxl-fix-gen-memleak

fix: VRAM memory leak in sdxl_gen_img.py
This commit is contained in:
Kohya S
2023-09-02 15:20:32 +09:00
committed by GitHub

3
sdxl_gen_img.py Normal file → Executable file
View File

@@ -761,6 +761,9 @@ class PipelineLike:
# we always cast to float32 as this does not cause significant overhead and is compatible with bfloa16 # we always cast to float32 as this does not cause significant overhead and is compatible with bfloa16
image = image.cpu().permute(0, 2, 3, 1).float().numpy() image = image.cpu().permute(0, 2, 3, 1).float().numpy()
if torch.cuda.is_available():
torch.cuda.empty_cache()
if output_type == "pil": if output_type == "pil":
# image = self.numpy_to_pil(image) # image = self.numpy_to_pil(image)
image = (image * 255).round().astype("uint8") image = (image * 255).round().astype("uint8")