Optimization solution 2 – enabling VAE tiling
Stable Diffusion VAE tiling is a technique that can be used to generate large images. It works by splitting an image into small tiles and then generating each tile separately. This technique allows the generation of large images without using too much VRAM.
Note that the result of tiled encoding and decoding will differ unnoticeably from the non-tiled version. Diffusers’ implementation of VAE tiling uses overlap tiles to blend edges to form a much smoother output.
You can turn on VAE tiling by adding the one-line code, text2img_pipe.enable_vae_tiling()
, before inferencing:
import torch from diffusers import StableDiffusionPipeline text2img_pipe = StableDiffusionPipeline.from_pretrained( Â Â Â Â "runwayml/stable-diffusion-v1-5", Â Â Â Â torch_dtype = torch.float16Â Â Â Â Â Â Â # <- load float16 version weight ).to("cuda:0") text2img_pipe...