This commit is contained in:
+63
-48
@@ -1,74 +1,89 @@
|
||||
# Use the official ROCm base image
|
||||
FROM ubuntu:26.04 AS reqs
|
||||
|
||||
# Set build variables
|
||||
ENV PIP_BREAK_SYSTEM_PACKAGES=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Set path variables
|
||||
ENV ROCM_PATH=/usr
|
||||
ENV HIP_PATH=/usr
|
||||
|
||||
# Install libraries
|
||||
RUN apt update -y && apt install -y --no-install-recommends \
|
||||
RUN apt update -y && \
|
||||
apt install -y --no-install-recommends \
|
||||
rocm \
|
||||
python3-pip \
|
||||
python3-dev \
|
||||
python3-torch-rocm \
|
||||
libhipblas-dev \
|
||||
librocblas-dev \
|
||||
hipcc \
|
||||
libhipblaslt-dev \
|
||||
libomp-22-dev \
|
||||
git \
|
||||
libgl1 \
|
||||
libglib2.0-bin \
|
||||
cmake \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
libavcodec-dev \
|
||||
libavformat-dev \
|
||||
libswresample-dev \
|
||||
libnuma-dev \
|
||||
build-essential \
|
||||
g++ \
|
||||
ninja-build \
|
||||
zlib1g-dev \
|
||||
libncurses5-dev \
|
||||
libgdbm-dev \
|
||||
libnss3-dev \
|
||||
libssl-dev \
|
||||
libreadline-dev \
|
||||
libffi-dev \
|
||||
libsqlite3-dev \
|
||||
wget \
|
||||
libbz2-dev \
|
||||
liblzma-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# SymLink for stability
|
||||
RUN ln -s /usr /opt/rocm
|
||||
# Build python3.12
|
||||
FROM reqs AS python312
|
||||
WORKDIR /build/python312
|
||||
RUN wget https://www.python.org/ftp/python/3.12.9/Python-3.12.9.tgz && \
|
||||
tar -xf Python-3.12.9.tgz && \
|
||||
cd Python-3.12.9 && \
|
||||
./configure --enable-optimizations && \
|
||||
make -j 80 && \
|
||||
make install && \
|
||||
wget https://bootstrap.pypa.io/get-pip.py && \
|
||||
python3 get-pip.py && \
|
||||
ln -s /usr/local/bin/pip3 /bin/pip && \
|
||||
ln -s /usr/local/bin/pip3 /bin/pip3 && \
|
||||
ln -s /usr/local/bin/python3 /bin/python && \
|
||||
ln -s /usr/local/bin/python3 /bin/python3.12
|
||||
|
||||
FROM reqs AS torch-audio
|
||||
# Build pytorch
|
||||
FROM python312 AS pytorch
|
||||
ENV CMAKE_ARGS="$CMAKE_ARGS -DUSE_KINETO=OFF"
|
||||
ENV PYTORCH_ROCM_ARCH=1100
|
||||
ENV USE_ROCM=1
|
||||
ENV USE_CUDA=0
|
||||
ENV ROCM_PATH=/usr
|
||||
ENV DEVICE_LIB_PATH=/usr/lib/llvm-21/lib/clang/21/amdgcn/bitcode
|
||||
ENV CMAKE_ARGS="-DCMAKE_HIP_COMPILER_WORKS=1 \
|
||||
-DCMAKE_CXX_COMPILER_WORKS=1 \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||
-DCMAKE_HIP_COMPILER_ROCM_LIB_PATH=$DEVICE_LIB_PATH \
|
||||
-DCMAKE_HIP_FLAGS=--rocm-device-lib-path=$DEVICE_LIB_PATH \
|
||||
-DCMAKE_C_COMPILER=/usr/lib/llvm-21/bin/clang \
|
||||
-DCMAKE_CXX_COMPILER=/usr/lib/llvm-21/bin/clang++ \
|
||||
-DCMAKE_HIP_COMPILER=/usr/lib/llvm-21/bin/clang++ \
|
||||
-DUSE_KINETO=OFF \
|
||||
-DUSE_OPENMP=OFF"
|
||||
|
||||
WORKDIR /builder
|
||||
|
||||
RUN git clone --depth 1 --branch v2.9.1 https://github.com/pytorch/audio.git && \
|
||||
cd audio && \
|
||||
WORKDIR /build/pytorch
|
||||
RUN git clone https://github.com/pytorch/pytorch.git && \
|
||||
cd pytorch && \
|
||||
git submodule update --init --recursive && \
|
||||
# Set path variables
|
||||
export CMAKE_PREFIX_PATH=/usr/lib/python3/dist-packages/torch/share/cmake && \
|
||||
export Torch_DIR=/usr/lib/python3/dist-packages/torch/share/cmake/Torch && \
|
||||
export hip_DIR=/usr/lib/aarch64-linux-gnu/cmake/hip && \
|
||||
export CMAKE_PREFIX_PATH="/usr/lib/python3/dist-packages/torch/share/cmake:/usr/lib/aarch64-linux-gnu/cmake/hip" && \
|
||||
# Set environment variables
|
||||
export PYTORCH_ROCM_ARCH=gfx1100 && \
|
||||
export HIP_VISIBLE_DEVICES=0 && \
|
||||
# Execute build
|
||||
USE_ROCM=1 BUILD_ROCM=1 CC=gcc CXX=g++ python3 setup.py install && \
|
||||
cd .. && rm -rf audio
|
||||
make triton && \
|
||||
python tools/amd_build/build_amd.py && \
|
||||
pip install -r requirements.txt && \
|
||||
export HIPFLAGS="--rocm-device-lib-path=$DEVICE_LIB_PATH" && \
|
||||
export CMAKE_ARGS="-DCMAKE_HIP_FLAGS=--rocm-device-lib-path=$DEVICE_LIB_PATH -DCMAKE_HIP_COMPILER_ROCM_LIB_PATH=$DEVICE_LIB_PATH -DCMAKE_C_COMPILER=/usr/lib/llvm-21/bin/clang -DCMAKE_CXX_COMPILER=/usr/lib/llvm-21/bin/clang++ -DCMAKE_HIP_COMPILER=/usr/lib/llvm-21/bin/clang++" && \
|
||||
python3 setup.py build && \
|
||||
python3 setup.py install
|
||||
|
||||
FROM torch-audio AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Clone ComfyUI
|
||||
# Build ComfyUI
|
||||
FROM pytorch AS comfyui
|
||||
RUN git clone https://github.com/comfyanonymous/ComfyUI.git .
|
||||
|
||||
# Create sub dependancy
|
||||
RUN grep -vE 'torch|nvidia|cuda|triton|kornia|spandrel' requirements.txt > req_no_torch.txt
|
||||
|
||||
# Install non torch dependant requirements
|
||||
RUN pip3 install --no-cache-dir --break-system-packages -r req_no_torch.txt
|
||||
|
||||
# Manually install the sensitive ones with --no-deps
|
||||
RUN pip3 install --no-deps --break-system-packages torchsde kornia spandrel
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
# Setup Manager
|
||||
WORKDIR /app/custom_nodes
|
||||
|
||||
Reference in New Issue
Block a user