Skip to content

Commit

Permalink
'rocm' Major upgrade to 6.3.1, Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
YanWenKun committed Dec 23, 2024
1 parent a589ae9 commit 3076d72
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 127 deletions.
183 changes: 116 additions & 67 deletions rocm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,93 +8,142 @@ FROM opensuse/tumbleweed:latest

LABEL maintainer="[email protected]"

# Note: GCC for InsightFace;
# FFmpeg for video (pip[imageio-ffmpeg] will use system FFmpeg instead of bundled);
# 'half' for ORT on ROCm.
RUN set -eu

################################################################################
# Python and tools

# Note: CMake may use different version of Python. Using 'update-alternatives' to ensure default version.
RUN --mount=type=cache,target=/var/cache/zypp \
set -eu \
&& zypper addrepo --check --refresh --priority 90 \
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++ python310-py-build-cmake \
python310-numpy1 python310-opencv \
python310-ffmpeg-python 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 -f /usr/lib64/python3.10/EXTERNALLY-MANAGED \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 10
install --no-confirm --auto-agree-with-licenses \
python312-devel \
python312-pip \
python312-wheel \
python312-setuptools \
python312-Cython \
python312-py-build-cmake \
python312-aiohttp \
python312-dbm \
python312-ffmpeg-python \
python312-GitPython \
python312-httpx \
python312-joblib \
python312-lark \
python312-matplotlib \
python312-mpmath \
python312-numba-devel \
python312-numpy1 \
python312-onnx \
python312-opencv \
python312-pandas \
python312-qrcode \
python312-rich \
python312-scikit-build \
python312-scikit-build-core-pyproject \
python312-scikit-image \
python312-scikit-learn \
python312-scipy \
python312-svglib \
python312-tqdm \
&& rm /usr/lib64/python3.12/EXTERNALLY-MANAGED \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 100

# Note: 'half' for ORT on ROCm.
RUN --mount=type=cache,target=/var/cache/zypp \
zypper --gpg-auto-import-keys \
install --no-confirm --auto-agree-with-licenses \
Mesa-libGL1 \
Mesa-libEGL-devel \
ghc-half \
libgthread-2_0-0 \
make \
ninja \
shadow \
git \
aria2 \
fish \
fd \
vim \
which \
opencv \
opencv-devel \
ffmpeg \
x264 \
x265 \
google-noto-sans-fonts \
google-noto-sans-cjk-fonts \
google-noto-coloremoji-fonts

################################################################################
# GCC 12
# GCC 13 does not implicitly include cstdint. Some repo needs fix before compile.
# So here we just use good old GCC 12.

RUN --mount=type=cache,target=/var/cache/zypp \
zypper --gpg-auto-import-keys \
install --no-confirm --auto-agree-with-licenses \
gcc12 \
gcc12-c++ \
cpp12 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-12 90 \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 90 \
&& update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-12 90 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 90 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 90 \
&& update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-12 90 \
&& update-alternatives --install /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-12 90 \
&& update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-12 90 \
&& update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-12 90 \
&& update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-12 90 \
&& update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-12 90

################################################################################
# Python Packages
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
pip list \
&& pip install \
--upgrade pip wheel setuptools

# Install PyTorch && ONNX from AMD repo
# https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/native_linux/install-pytorch.html
# https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/native_linux/install-onnx.html
# Using torchaudio CPU for compatibility
# The extra index of PyTorch has no use here, just a fail-safe.
# Deps for ComfyUI & custom nodes
COPY builder-scripts/. /builder-scripts/

RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.2.3/torch-2.3.0%2Brocm6.2.3-cp310-cp310-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.2.3/torchvision-0.18.0%2Brocm6.2.3-cp310-cp310-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.2.3/pytorch_triton_rocm-2.3.0%2Brocm6.2.3.5a02332983-cp310-cp310-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.2.3/onnxruntime_rocm-1.18.0-cp310-cp310-linux_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.2/jaxlib-0.4.23%2Brocm620-cp310-cp310-manylinux2014_x86_64.whl \
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.2/rocpydecode-1.0.0.0-py3-none-manylinux_2_28_x86_64.whl \
https://download.pytorch.org/whl/cpu/torchaudio-2.3.0%2Bcpu-cp310-cp310-linux_x86_64.whl \
--extra-index-url https://download.pytorch.org/whl/rocm6.2

# Dependencies for frequently-used
pip install \
-r /builder-scripts/pak1.txt

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/ltdrdata/ComfyUI-Manager/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/jags111/efficiency-nodes-comfyui/main/requirements.txt \
--extra-index-url https://download.pytorch.org/whl/rocm6.2

# Dependencies for more, with few hand-pick:
# 'compel lark' for smZNodes
# 'torchdiffeq' for DepthFM
# 'fairscale' for APISR
pip install \
-r /builder-scripts/pak3.txt

RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
-r https://raw.githubusercontent.com/crystian/ComfyUI-Crystools/main/requirements.txt \
-r https://raw.githubusercontent.com/cubiq/ComfyUI_FaceAnalysis/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/ltdrdata/ComfyUI-Impact-Pack/Main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Impact-Subpack/main/requirements.txt \
-r https://raw.githubusercontent.com/ltdrdata/ComfyUI-Inspire-Pack/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/rocm6.2

# Fix MediaPipe's broken dep (protobuf<4).
pip install \
-r /builder-scripts/pak5.txt

RUN --mount=type=cache,target=/root/.cache/pip \
pip install --break-system-packages \
mediapipe \
pip install \
-r /builder-scripts/pak7.txt

# Make sure the deps fit the needs for ComfyUI & Manager
RUN --mount=type=cache,target=/root/.cache/pip \
pip install \
-r https://github.com/comfyanonymous/ComfyUI/raw/refs/heads/master/requirements.txt \
-r https://github.com/ltdrdata/ComfyUI-Manager/raw/refs/heads/main/requirements.txt \
&& pip list

################################################################################

RUN df -h \
&& du -ah /root \
&& find /root/ -mindepth 1 -delete

COPY runner-scripts/. /runner-scripts/

RUN groupadd -r video
# For ROCm
RUN groupadd --system video

USER root
VOLUME /root
WORKDIR /root
Expand Down
36 changes: 36 additions & 0 deletions rocm/builder-scripts/generate-pak5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -eu

echo '#' > pak5.txt

array=(
https://github.com/comfyanonymous/ComfyUI/raw/refs/heads/master/requirements.txt
https://github.com/ltdrdata/ComfyUI-Manager/raw/refs/heads/main/requirements.txt
https://github.com/cubiq/ComfyUI_essentials/raw/refs/heads/main/requirements.txt
https://github.com/cubiq/ComfyUI_FaceAnalysis/raw/refs/heads/main/requirements.txt
https://github.com/cubiq/ComfyUI_InstantID/raw/refs/heads/main/requirements.txt
https://github.com/cubiq/PuLID_ComfyUI/raw/refs/heads/main/requirements.txt
https://github.com/Fannovel16/comfyui_controlnet_aux/raw/refs/heads/main/requirements.txt
https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite/raw/refs/heads/main/requirements.txt
https://github.com/ltdrdata/ComfyUI-Impact-Pack/raw/refs/heads/Main/requirements.txt
https://github.com/ltdrdata/ComfyUI-Impact-Subpack/raw/refs/heads/main/requirements.txt
https://github.com/ltdrdata/ComfyUI-Inspire-Pack/raw/refs/heads/main/requirements.txt
https://github.com/WASasquatch/was-node-suite-comfyui/raw/refs/heads/main/requirements.txt
)

for line in "${array[@]}";
do curl -w "\n" -sSL "${line}" >> pak5.txt
done

sed -i '/^#/d' pak5.txt
sed -i 's/[[:space:]]*$//' pak5.txt
sed -i 's/>=.*$//' pak5.txt
sed -i 's/_/-/g' pak5.txt

# Don't "sort foo.txt >foo.txt". See: https://stackoverflow.com/a/29244408
sort -ufo pak5.txt pak5.txt

# Remove duplicate items, compare to pak3.txt
grep -Fixv -f pak3.txt pak5.txt > temp.txt && mv temp.txt pak5.txt

echo "<pak5.txt> generated. Check before use."
10 changes: 10 additions & 0 deletions rocm/builder-scripts/pak1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Ref: https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/native_linux/install-pytorch.html
# Ref: https://rocm.docs.amd.com/projects/radeon/en/latest/docs/install/native_linux/install-onnx.html
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/apex-1.4.0%2Brocm6.3.1-cp312-cp312-linux_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/jaxlib-0.4.31-cp312-cp312-manylinux_2_28_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/onnxruntime_rocm-1.19.0-cp312-cp312-linux_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/pytorch_triton_rocm-3.0.0%2Brocm6.3.1.75cc27c26a-cp312-cp312-linux_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/rocpydecode-0.2.0.0-py3-60301-manylinux_2_28_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/torch-2.4.0%2Brocm6.3.1-cp312-cp312-linux_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/torchaudio-2.4.0%2Brocm6.3.1-cp312-cp312-linux_x86_64.whl
https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3.1/torchvision-0.19.0%2Brocm6.3.1-cp312-cp312-linux_x86_64.whl
30 changes: 30 additions & 0 deletions rocm/builder-scripts/pak3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 'compel lark' for smZNodes
# 'torchdiffeq' for DepthFM
# 'fairscale' for APISR
accelerate
compel
diffusers
fairscale
ftfy
huggingface-hub[hf-transfer]
imageio
joblib
kornia
lark
matplotlib
onnx
opencv-contrib-python-headless
pandas
pilgram
pillow
pygit2
python-ffmpeg
regex
scikit-build-core
scikit-image
scikit-learn
scipy
timm
torchdiffeq
torchmetrics
transformers
42 changes: 42 additions & 0 deletions rocm/builder-scripts/pak5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
addict
aiohttp
albumentations
cachetools
color-matcher
colour-science
dill
einops
filelock
fvcore
GitPython
imageio-ffmpeg
importlib-metadata
matrix-client==0.4.0
mediapipe
numba
omegaconf
piexif
pixeloe
psutil
PyGithub
python-dateutil
pyyaml
rembg
rich
safetensors
segment-anything
sentencepiece
soundfile
spandrel
svglib
tokenizers
torchsde
tqdm
transparent-background
trimesh[easy]
typer
typing-extensions
ultralytics
webcolors
yacs
yapf
7 changes: 7 additions & 0 deletions rocm/builder-scripts/pak7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dlib
facexlib
insightface
git+https://github.com/openai/CLIP.git
git+https://github.com/WASasquatch/cstr.git
git+https://github.com/WASasquatch/ffmpy.git
git+https://github.com/WASasquatch/img2texture.git
Loading

0 comments on commit 3076d72

Please sign in to comment.