はじめに
使用したのはこちらです。github.com
NVIDIAが開発したものをIntel GPUで実行してみました。
DIffusersがそれを可能にしてくれています。
PC環境
Ubuntu 24.04 Intel Arc A770 (VRAM 16GB) Python 3.12
Python環境構築
pip install torch --index-url https://download.pytorch.org/whl/test/xpu pip install git+https://github.com/huggingface/diffusers pip install transformers accelerate beautifulsoup4 ftfy
PyTorchの使い方はこちらを見て下さい。
touch-sp.hatenablog.com
実行
PAGのありなしで画像を生成しています。PAGについてはこちらを見て下さい。touch-sp.hatenablog.com
CPUやメモリが一緒じゃないので単純に比較はできませんがRTX 3080 Laptop(VRAM 16GB)よりも生成速度が速かったです。
No PAG
Pythonスクリプト
import torch from diffusers import SanaPipeline from decorator import time_monitor @time_monitor def main(): pipe = SanaPipeline.from_pretrained( "Efficient-Large-Model/Sana_1600M_1024px_BF16_diffusers", variant="bf16", torch_dtype=torch.bfloat16, ).to("xpu") pipe.text_encoder.to(torch.bfloat16) pipe.vae.to(torch.bfloat16) prompt = 'a cyberpunk cat with a neon sign that says "Sana"' image = pipe( prompt=prompt, guidance_scale=5.0, num_inference_steps=20, generator=torch.Generator(device="xpu").manual_seed(42), )[0] image[0].save('no_pag.jpg') if __name__ == "__main__": main()
結果
time: 11.82 sec

With PAG
Pythonスクリプト
import torch from diffusers import SanaPAGPipeline from decorator import time_monitor @time_monitor def main(): pipe = SanaPAGPipeline.from_pretrained( "Efficient-Large-Model/Sana_1600M_1024px_BF16_diffusers", variant="bf16", torch_dtype=torch.bfloat16, pag_applied_layers="transformer_blocks.8", ).to("xpu") pipe.text_encoder.to(torch.bfloat16) pipe.vae.to(torch.bfloat16) prompt = 'a cyberpunk cat with a neon sign that says "Sana"' image = pipe( prompt=prompt, guidance_scale=5.0, pag_scale=2.0, num_inference_steps=20, generator=torch.Generator(device="xpu").manual_seed(42), )[0] image[0].save('with_pag.jpg') if __name__ == "__main__": main()
結果
time: 13.37 sec
