PaddlePaddle / PaddleMIX

Paddle Multimodal Integration and eXploration, supporting mainstream multi-modal tasks, including end-to-end large-scale multi-modal pretrain models and diffusion model toolbox. Equipped with high performance and flexibility.
Apache License 2.0
242 stars 101 forks source link

性能这么差,sd1.5 16G显存都运行不了? #97

Open lrjxgl opened 10 months ago

lrjxgl commented 10 months ago

Out of memory error on GPU 0. Cannot allocate 5.062500GB memory on GPU 0, 12.043945GB memory has been allocated and available memory is only 2.956055GB.

官方demo: from paddlemix import Appflow import paddle paddle.seed(1024) task = Appflow(app="text2image_generation", models=["stabilityai/stable-diffusion-v1-5"] ) prompt = "a photo of an astronaut riding a horse on mars." result = task(prompt=prompt)['result']

lx1054331851 commented 10 months ago

按照教程,完全运行不起来,你还能运行的起来

JunnYu commented 10 months ago

更新ppdiffusers、pip install -U ppdiffusers 你好,建议使用ppdiffusers目录下的代码运行,当前appflow可能会存在问题 (你使用的代码采用了float32精度,未开启xformers,默认生成图片大小为768x768,这些原因会导致你在16G显卡上无法正常运行!)。 https://github.com/PaddlePaddle/PaddleMIX/blob/develop/ppdiffusers/examples/inference/text_to_image_generation-stable_diffusion.py 下面的命令使用了

显存占用:

import paddle
from ppdiffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", safety_checker=None, paddle_dtype=paddle.float16)
# 如果无法使用xformers,请注释下面的内容。
pipe.enable_xformers_memory_efficient_attention()
prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt, height=512, width=512, guidance_scale=7.5).images[0]
image.save("text_to_image_generation-stable_diffusion-result.png")