Steps to run SD.Next with Intel Arc GPU on native windows (IPEX) #2023
Replies: 8 comments 59 replies
-
Thanks! Btw, this should probably be a Wiki page? |
Beta Was this translation helpful? Give feedback.
-
to tackle the tbb version probleme instead of opening any cmd shell you can open the terminal named "Intel oneAPI command prompt for Intel 64 for Visual Studio 2022", i think it is created when you install the VS integration part of OneApi . it will automaticaly source the setvars and apparently do a little more than that. Now i'm facing no error or warning in the sd.next log but it does take a awfull lot of time to load a model and more specificaly the embedding part of the checkpoint up to 100 secondes just for that. On wsl2 it only take a few seconds. After it ultimately load and is finally ready it won't start generating anything. it juste hang there writing nothing in the log file. here is the sdnext logs and the python packages installed. |
Beta Was this translation helpful? Give feedback.
-
Fun facts:
|
Beta Was this translation helpful? Give feedback.
-
Updated (rewrited) the tutorial. I think this would be a much simpler setup than the old one. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry if I'm asking something quite basic, but I've not found a clear answer elsewhere. I've followed the directions as closely as possible, but I don't know what to do in this step: "Override the TORCH_COMMAND environment to let SD.Next install torch, torchvision and ipex from local wheels". I've downloaded the files in the correct folder, but I don't know wich file do I have to modify to override the settings. |
Beta Was this translation helpful? Give feedback.
-
I'm in a weird place. I can't get this to work, though I suspect user error somewhere. I did follow the instructions step-by-step. It installed everything without error. I'm using Linux Mint with an Arc770 16GB by the way. I've slapped that button to make sure the settings are all default, just so we can start with a baseline. Now, if I load an XL model and try to run one 1024x1024 image, the error I get is "RuntimeError: could not create an engine". The traceback call above it gives me this: /media/whackjob/16Tons/STABLE DIFFUSION/automatic/modules/call_queue.py:34 │ |
Beta Was this translation helpful? Give feedback.
-
Updated (edited the description, just scroll up): I baked all the dll dependencies ( Users should be able to simply launch SD.Next (dev branch for now) with |
Beta Was this translation helpful? Give feedback.
-
Well, I'm back to being down. Now I get this:
|
Beta Was this translation helpful? Give feedback.
-
Preparations
Intel GPU Driver
properly (but not 4885 nor 4887, see Drivers from 4885 and newer break IPEX for native windows. intel/intel-extension-for-pytorch#442)git
.python 3.10
(I only built wheels for python 3.10)Starting from scratch
The latest IPEX wheels (built from source by myself, NOT an official release from INTEL) have been added to
dev
branch by @Disty0.Arc users should be able to launch SD.Next directly without needing to manually install any extra dependencies!!
Performance
IPEX native windows is ~20% slower than WSL or Linux for low resolutions. See details by filtering "ipex" at https://vladmandic.github.io/sd-extension-system-info/pages/benchmark.html.
Why did I build IPEX from source (TL;DR)
Issue of current official IPEX wheel
Intel released IPEX wheels for native windows in Aug'23. However, the official IPEX wheel was built without AOT (Ahead Of Time) compilation support, which dramatically degrades the user experience for IPEX windows -- there's a JIT (Just-In-Time) compilation overhead in the order of 10 minutes (depending on your CPU) each time you start the Web UI, load model weights or change image generation parameter. See intel/intel-extension-for-pytorch#399 for details. In my opinion, this makes IPEX not usable on native Windows.
Building IPEX wheel from source with AOT support
To overcome the above issue, community folks (including me) started to build the IPEX wheel from source since Intel didn't provide a clear ETA for an official AOT wheel release.
The IPEX AOT wheel reduces the warmup overhead from ~10 minutes to ~10 seconds as expected! So I'd like to share the wheels that I built with Python 3.10 and Nuullll/intel-extension-for-pytorch@c6ea20b (which took ~4 hours for i9-13900 + 32GB RAM).
oneAPI dependencies
Previously it was common sense that one needed to install the oneAPI components (DPCPP compiler and MKL) system-wide to be able to use IPEX. Recently I found out that we can actually bake all dll dependencies into the python wheel, so that we don't have to manually install oneAPI any more. You can check repack_wheels.bat to see how I re-package the torch and ipex wheels.
Below is outdated
Install Miniconda (or Anaconda)
Miniconda3 - Python 3.10
installer for Windows: https://docs.conda.io/en/latest/miniconda.html#windows-installersIt's highly recommended to use a conda virtual environment instead of SD.Next's default virtualenv. We will need to install some dll dependencies (e.g., oneAPI components, libuv) and conda will automatically put the corresponding dlls into the library path.
Prepare conda virtual environment for SD.Next
Anaconda Prompt (miniconda3)
. At this time you will be in thebase
environment.sdnext
)Install dll dependencies in the conda environment (
sdnext
)libuv
Otherwise, you may encounter the following error when trying to
import torch
later:These are the minimal requirements for running IPEX. And we don't even have to activate oneAPI environment with
setvars.bat
-- all required dlls will be put into the library path when we activate thesdnext
conda environment.Prepare SD.Next folder
Then put all the downloaded wheels into the SD.Next root folder
automatic\
Launch SD.Next with
launch.py
directlyMake sure you're in the
sdnext
conda environment.Override the
TORCH_COMMAND
environment to let SD.Next install torch, torchvision and ipex from local wheels, then we're all set!Logs:
Re-launch SD.Next later
Simply launch an
Anaconda Prompt (miniconda3)
. Then activate thesdnext
conda environment and executelaunch.py
with--use-ipex
.You may notice the following false alarm:
The reason is that there's no
sycl-ls
executable (it's not necessary at all) inside the conda environment, but we indeed have all the required oneAPI libraries. So just ignore it. I'll file a PR to remove this false alarm.Beta Was this translation helpful? Give feedback.
All reactions