Skip to content

Commit

Permalink
Rehaul ROCm
Browse files Browse the repository at this point in the history
  • Loading branch information
YanWenKun committed Apr 3, 2024
1 parent d54b789 commit 80e9b6a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 22 deletions.
69 changes: 49 additions & 20 deletions Dockerfile-rocm
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,79 @@ FROM opensuse/tumbleweed:latest
LABEL maintainer="code@yanwk.fun"

# Note: GCC for InsightFace, FFmpeg for video
# 'half' for ORT on ROCm
RUN --mount=type=cache,target=/var/cache/zypp \
set -eu \
&& zypper install --no-confirm \
python311 python311-pip python311-wheel python311-setuptools \
python311-devel python311-Cython gcc-c++ cmake \
python311-av python311-ffmpeg-python python311-numpy ffmpeg \
&& zypper addrepo --check --refresh --priority 90 \
'https://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Tumbleweed/Essentials/' packman-essentials \
&& zypper --gpg-auto-import-keys \
install --no-confirm \
python310 python310-pip python310-wheel python310-setuptools \
python310-devel python310-Cython gcc-c++ cmake \
python310-ffmpeg-python python310-numpy ffmpeg x264 x265 \
python310-dbm \
ghc-half \
google-noto-sans-fonts google-noto-sans-cjk-fonts google-noto-coloremoji-fonts \
shadow git aria2 \
Mesa-libGL1 libgthread-2_0-0 \
&& rm /usr/lib64/python3.11/EXTERNALLY-MANAGED
&& rm -f /usr/lib64/python3.10/EXTERNALLY-MANAGED

RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
--upgrade pip wheel setuptools Cython numpy

# Install PyTorch nightly
# Install PyTorch from AMD repo
# https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/install-pytorch.html
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
--pre torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/rocm6.0
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.0.2/torch-2.1.2%2Brocm6.0-cp310-cp310-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.0.2/torchvision-0.16.1%2Brocm6.0-cp310-cp310-linux_x86_64.whl \
--extra-index-url https://download.pytorch.org/whl/nightly/rocm6.0

# Dependencies for: ComfyUI,
# InstantID, ControlNet Auxiliary Preprocessors, Frame Interpolation,
# ComfyUI-Manager, Inspire-Pack, Impact-Pack, "Essentials", Face Analysis,
# Efficiency Nodes, Crystools, FizzNodes, smZNodes(compel, lark),
# DepthFM(torchdiffeq), APISR(fairscale)
# Dependencies for frequently-used
# (Do this firstly so PIP won't be solving too many deps at one time)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
-r https://raw.githubusercontent.com/comfyanonymous/ComfyUI/master/requirements.txt \
-r https://raw.githubusercontent.com/ZHO-ZHO-ZHO/ComfyUI-InstantID/main/requirements.txt \
-r https://raw.githubusercontent.com/crystian/ComfyUI-Crystools/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_essentials/main/requirements.txt \
-r https://raw.githubusercontent.com/Fannovel16/comfyui_controlnet_aux/main/requirements.txt \
-r https://raw.githubusercontent.com/Fannovel16/ComfyUI-Frame-Interpolation/main/requirements-no-cupy.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Inspire-Pack/main/requirements.txt \
-r https://raw.githubusercontent.com/jags111/efficiency-nodes-comfyui/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Impact-Pack/Main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Impact-Subpack/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_essentials/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Inspire-Pack/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/requirements.txt \
--extra-index-url https://download.pytorch.org/whl/nightly/rocm6.0

# Dependencies for more, with few hand-pick:
# 'cupy-cuda12x' for Frame Interpolation
# 'compel lark' for smZNodes
# 'torchdiffeq' for DepthFM
# 'fairscale' for APISR
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_FaceAnalysis/main/requirements.txt \
-r https://raw.githubusercontent.com/jags111/efficiency-nodes-comfyui/main/requirements.txt \
-r https://raw.githubusercontent.com/crystian/ComfyUI-Crystools/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_InstantID/main/requirements.txt \
-r https://raw.githubusercontent.com/Fannovel16/ComfyUI-Frame-Interpolation/main/requirements-no-cupy.txt \
-r https://raw.githubusercontent.com/FizzleDorf/ComfyUI_FizzNodes/main/requirements.txt \
-r https://raw.githubusercontent.com/kijai/ComfyUI-KJNodes/main/requirements.txt \
-r https://raw.githubusercontent.com/melMass/comfy_mtb/main/requirements.txt \
-r https://raw.githubusercontent.com/storyicon/comfyui_segment_anything/main/requirements.txt \
-r https://raw.githubusercontent.com/ZHO-ZHO-ZHO/ComfyUI-InstantID/main/requirements.txt \
compel lark torchdiffeq fairscale \
python-ffmpeg \
--extra-index-url https://download.pytorch.org/whl/nightly/rocm6.0

# 1. Force-Reinstall ONNX for ROCm
# Ref: https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/install-onnx.html
# 2. Fix MediaPipe's broken dep (protobuf<4).
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
--force-reinstall \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.0.2/onnxruntime_rocm-inference-1.17.0-cp310-cp310-linux_x86_64.whl \
&& pip install --break-system-packages \
mediapipe

# Create a low-privilege user.
RUN printf 'CREATE_MAIL_SPOOL=no' > /etc/default/useradd \
&& mkdir -p /home/runner /home/scripts \
Expand Down
8 changes: 7 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ Once the app is loaded, visit http://localhost:8188/
[[rocm]]
## Usage - AMD GPU (Experimental)

NOTE: If you are using WSL2 with AMD/Intel GPU, consider *link:docs/wsl-directml.adoc[Run ComfyUI on WSL2 with DirectML]*
NOTE: Recommend AMD users to run ComfyUI on Windows with ZLUDA. Running on Linux needs some experience.

NOTE: If you are using WSL2 with AMD/Intel GPU, consider *link:docs/wsl-directml.adoc[Run ComfyUI on WSL2 with DirectML]*.

NOTE: On Linux hosts, install
https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/install-radeon.html[Radeon software for Linux with ROCm]
first.

.C. Using `docker compose`
[source,sh]
Expand Down
7 changes: 6 additions & 1 deletion README.zh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ docker pull yanwk/comfyui-boot:latest
[[rocm]]
## 运行方法 - AMD 显卡(尚在实验)

NOTE: AMD/Intel GPU + Win11 可以考虑: *link:docs/wsl-directml.zh.adoc[在 WSL2 环境下通过 DirectML 运行 ComfyUI]*
NOTE: 推荐 AMD 用户使用 Win11 + ZLUDA 方式运行,安装 AMD HIP SDK 并使用常见整合包运行即可(不要开启 xFormers),初次运行会花 15 分钟左右来编译代码,之后就和 CUDA 体验差不多了。不推荐缺乏经验的用户折腾 Linux 下的 ROCm。

NOTE: WSL2 + AMD/Intel GPU 可以考虑: *link:docs/wsl-directml.zh.adoc[在 WSL2 环境下通过 DirectML 运行 ComfyUI]*

NOTE: Linux 宿主机需要安装
https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/install-radeon.html[Radeon software for Linux with ROCm] 以让 Docker 支持 GPU,各发行版可能安装方式不同。

.方法 C 使用 `docker compose`
[source,sh]
Expand Down
1 change: 1 addition & 0 deletions docker-compose-rocm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
# --security-opt seccomp=unconfined

comfyui:
init: true
container_name: comfyui
depends_on:
file-chown:
Expand Down

0 comments on commit 80e9b6a

Please sign in to comment.