Sunday, May 26, 2024

Stable Diffusion on Intel Arc A770? Sure!

 




"Dolphin light show, frutiger aero"

The alchemist GPU can do all kinds of sorcery with Intel's extension for PyTorch. The above is a pretty good example.


If you are on Windows, you can follow the steps here for the initial setup:


After setting up MSVC and OneAPI Base Toolkit, I suggest using Miniconda3 and the "Anaconda Prompt" (search in the Start Menu). Run as Administrator, and run these two commands before proceeding to install/use Intel's PyTorch extensions:

"C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
"C:\Program Files (x86)\Intel\oneAPI\mkl\latest\env\vars.bat"

The locations can vary on your system, and you will need to do this every time you plan to use PyTorch. 

I used the following code in a Jupyter notebook. You might need to install a few packages (such as diffusers) before running it successfully.

from diffusers import DiffusionPipeline
import intel_extension_for_pytorch as ipex
import torch

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
pipe.to("xpu")

prompt = "Dolphin light show, frutiger aero"

image = pipe(prompt=prompt).images[0]
image.save("dolphinlightshow.png")


No comments:

Post a Comment

Stable Diffusion on Intel Arc A770? Sure!

  "Dolphin light show, frutiger aero" The alchemist GPU can do all kinds of sorcery with Intel's extension for PyTorch. The ab...