simonlui / Docker_IPEX_ComfyUI

Stable Diffusion ComfyUI Docker/OCI Image for Intel Arc GPUs
Apache License 2.0
27 stars 2 forks source link

Stable Diffusion ComfyUI Docker/OCI Image for Intel Arc GPUs

This Docker/OCI image is designed to run ComfyUI inside a Docker/OCI container for Intel Arc GPUs. This work was based in large part on the work done by a Docker image made by nuullll here for a different Stable Diffusion UI and the official Docker images from the Intel® Extension for PyTorch* xpu-main branch Docker images here.

The Docker/OCI image includes

Intel Extension for Pytorch (IPEX) and other python packages and dependencies will be installed upon first launch of the container. They will be installed in a Python virtual environment in a separate volume to allow for reuse between containers and to make rebuilding images in between changes a lot faster.

Prerequisites

There are reports that Intel® Xe GPUs (iGPU and dGPU) in Tiger Lake (11th generation) and newer Intel processors are also capable of running oneAPI but this has not been tested and it seems to rely on custom compilation of the software yourself. Feel free to file any issues if this is the case as the infrastructure is there for support to be implemented, it seems. Otherwise, any other Intel GPUs are unfortunately not supported and will need to have its support enabled by Intel for oneAPI. If you are in such a position and want to run Stable Diffusion with an older Intel GPU, ComfyUI and this repository won't be able to do that for you at this time but please take a look at Intel's OpenVINO fork of stable-diffusion-webui located here for a way to possibly do that.

Windows should work, but it is highly not recommended to run this unless you have a specific reason to do so i.e. needing a Linux host/userspace to run custom nodes or etc. For most purposes, doing a native install will give better speeds and less headaches. Please follow the install instructions listed in the ComfyUI README.md

Build and run the image

Instructions will assume Docker but podman has command compatibility so it should be easy to replace docker in these commands to run also. Run the following command in a terminal to checkout the repository and build the image.

git clone https://github.com/simonlui/Docker_IPEX_ComfyUI
cd Docker_IPEX_ComfyUI
docker build -t ipex-arc-comfy:latest -f Dockerfile .

Once the image build is complete, then run the following if using Linux in terminal or Docker Desktop.

docker run -it `
--device /dev/dri `
-e ComfyArgs="<ComfyUI command line arguments>" `
--name comfy-server`  
--network=host `
--security-opt=label=disable `
-v <Directory to mount ComfyUI>:/ComfyUI:Z `
-v deps:/deps `
-v huggingface:/root/.cache/huggingface `
-e ComfyArgs="<ComfyUI command line arguments>" `
ipex-arc-comfy:latest

For Windows, run the following in terminal or Docker Desktop.

docker run -it `
--device /dev/dxg `
-e ComfyArgs="<ComfyUI command line arguments>" `
--name comfy-server`
-p 8188:8188 `
-v /usr/lib/wsl:/usr/lib/wsl `
-v <Directory to mount ComfyUI>:/ComfyUI:Z `
-v deps:/deps `
-v huggingface:/root/.cache/huggingface `
ipex-arc-comfy:latest

You must replace the <> text in the above commands with your own text. Copying the commands without modification will not run.

Below is an explanation on what the above commands mean so one will know how to modify the command correctly to run the image if you are not familiar with Docker or podman. The arguments can be ordered in any way as long as docker run and ipex-arc-comfy:latest stay in the locations specified.

Afterwards, one should be able to see that everything runs. To stop a container, you can run docker stop comfy-server to stop the container. To resume, you should run docker start -ai comfy-server.

Additional Options

Please refer to the Dockerfile for all available build arguments and environment variables not mentioned here and documented.