Stable Diffusion Inference for Text2Image on Intel GPU¶
Introduction¶
Intel® Extension for TensorFlow* is compatible with stock TensorFlow*. This example shows Stable Diffusion Inference for Text2Image.
Install the Intel® Extension for TensorFlow* in legacy running environment, Tensorflow will execute the Inference on Intel GPU.
Hardware Requirements¶
Verified Hardware Platforms:
Intel® Data Center GPU Max Series
Intel® Data Center GPU Flex Series 170
Prerequisites¶
Model Code change¶
We optimized official keras-cv Stable Diffusion, for example, concatenate two forward passes, combine computation in loops to reduce op number, and add fp16 mode for model. However, this optimization hasn’t been up streamed. To get better performance, instead of installing official keras-cv, you may want to clone keras-cv, apply patch, then install it as shown here:
git clone https://github.com/keras-team/keras-cv.git
cd keras-cv
git reset --hard f2de9510460fe8368c23df8fd168827c02c45679
git apply patch
pip install .
Example Output¶
With successful execution, it will print out the following results:
50/50 [==============================] - 4s 88ms/step
Start plotting the generated images to fp16_1imgs_50steps.png
FAQ¶
If you get the following error log, refer to Enable Running Environment to Enable oneAPI running environment.
tensorflow.python.framework.errors_impl.NotFoundError: libmkl_sycl.so.2: cannot open shared object file: No such file or directory