Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 2.14 KB

File metadata and controls

53 lines (38 loc) · 2.14 KB

Quick Start for Stable Diffusion Inference

Stable Diffusion is a latent text-to-image diffusion model. More details could be found in Stable Diffusion v1 and Stable Diffusion v2.

Requirements

1. Install intel-extension-for-openxla

please got the main page, and follow the instructions to build and install intel-extension-for-openxla.

2. Install packages

Mark intel-extension-for-openxla folder as <WORKSPACE>, then

cd <WORKSPACE>/example/stable_diffusion/
pip install transformers==4.38 diffusers==0.26.3 datasets==2.20.0 msgpack==1.0.7
pip install -r ../../test/requirements.txt

Run

1. Environmental Variables

ENV Description PVC Platform ATSM/DG2 Platform
ZE_AFFINITY_MASK Run this model on single GPU tile export ZE_AFFINITY_MASK=0 export ZE_AFFINITY_MASK=0
XLA_FLAGS Customize xla debug options export XLA_FLAGS="--xla_gpu_force_conv_nhwc" export XLA_FLAGS="--xla_gpu_force_conv_nhwc"

2. Inference Command

Model Output Image Resolution Command
CompVis/stable-diffusion-v1-4 512x512 python jax_stable.py
stabilityai/stable-diffusion-2 768x768 python jax_stable.py -m stabilityai/stable-diffusion-2
stabilityai/stable-diffusion-2-1 768x768 python jax_stable.py -m stabilityai/stable-diffusion-2-1

Add option --accuracy to check whether the demo result is expected. Output range is 0~1, higher is better:

python jax_stable.py -m stabilityai/stable-diffusion-2-1 --accuracy

Expected Output

Performance

Average Latency per image is: x.xxx s
Average Throughput per second is: x.xxx steps

Accuracy

RMSE accuracy is: 0.976