diff --git a/comfyui-rocm-dockerfile b/comfyui-rocm-dockerfile index ccb4eb7..78adcab 100644 --- a/comfyui-rocm-dockerfile +++ b/comfyui-rocm-dockerfile @@ -1,21 +1,30 @@ -# Use the official ROCm base image +# Use the LTS Ubuntu repo FROM ubuntu:26.04 AS reqs -# Set build variables +# Set global build variables ENV PIP_BREAK_SYSTEM_PACKAGES=1 ENV PYTHONUNBUFFERED=1 ENV DEBIAN_FRONTEND=noninteractive +ENV MAX_JOBS=10 # Install libraries RUN apt update -y && \ apt upgrade -y && \ apt install -y --no-install-recommends \ ca-certificates \ - rocm \ - hipcc \ - libhipblaslt-dev \ - libomp-22-dev \ + wget \ + curl \ git \ + gfortran \ + ninja-build \ + g++ \ + pkg-config \ + xxd \ + automake \ + libtool \ + libegl1-mesa-dev \ + texinfo \ + bison \ + flex \ cmake \ - libnuma-dev \ build-essential \ zlib1g-dev \ libncurses5-dev \ @@ -30,18 +39,16 @@ RUN apt update -y && \ libreadline-dev \ libffi-dev \ libsqlite3-dev \ - libnuma-dev \ libelf-dev \ libpciaccess-dev \ protobuf-compiler \ libprotobuf-dev \ - wget \ libbz2-dev \ liblzma-dev \ && rm -rf /var/lib/apt/lists/* + # Tested Working - -# Build python +# Build python 3.11 FROM reqs AS python WORKDIR /build/python RUN wget https://www.python.org/ftp/python/3.11.15/Python-3.11.15.tgz && \ @@ -57,10 +64,37 @@ RUN wget https://www.python.org/ftp/python/3.11.15/Python-3.11.15.tgz && \ ln -s /usr/local/bin/pip3 /bin/pip3 && \ ln -s /usr/local/bin/python3 /bin/python && \ ln -s /usr/local/bin/python3 /bin/python3.11 + # Tested Working +# Build ROCm latest +FROM python AS ROCm +WORKDIR /build/therock +ENV CFLAGS="-Wno-error=discarded-qualifiers -fcommon -w" +ENV CXXFLAGS="-Wno-error=discarded-qualifiers -fcommon -w" +RUN git clone https://github.com/ROCm/TheRock.git && \ + cd TheRock && \ + git submodule update --init --recursive && \ + env INSTALL_PREFIX=/usr/local ./dockerfiles/install_pinned_patchelf.sh && \ + pip install -r requirements.txt && \ + cmake -S . -B build \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DTHEROCK_AMDGPU_TARGETS="gfx1100" \ + -DTHEROCK_DIST_AMDGPU_FAMILIES="gfx1100" \ + -DTHEROCK_AMDGPU_DIST_BUNDLE_NAME="gfx1100" \ + -DLLVM_HOST_TRIPLE="aarch64-unknown-linux-gnu" \ + -DLLVM_DEFAULT_TARGET_TRIPLE="aarch64-unknown-linux-gnu" \ + -DCMAKE_C_FLAGS="$CFLAGS" \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi" \ + -DLLVM_ENABLE_PROJECTS="clang;lld;flang" \ + -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ + -DCMAKE_INSTALL_PREFIX=./install && \ + cmake --build build -- -j${MAX_JOBS} + # Work in progress [ Breaking due to x86 intrinsics not ported to Aarch64 ] # Build pytorch -FROM python AS pytorch +FROM ROCm AS pytorch # Setup Envronment ENV PYTORCH_ROCM_ARCH=1100 ENV USE_ROCM=1 @@ -68,18 +102,16 @@ ENV USE_CUDA=0 ENV USE_AOTRITON=0 ENV USE_SYSTEM_PTHREADPOOL=1 ENV USE_SYSTEM_PROTOC=1 -ENV USE_ONNX=OFF ENV BUILD_CUSTOM_PROTOBUF=OFF -ENV USE_XNNPACK=OFF -ENV USE_XNNPACK=OFF -ENV USE_QNNPACK=OFF ENV USE_PYTORCH_QNNPACK=OFF +ENV USE_XNNPACK=OFF +ENV USE_ONNX=OFF +ENV USE_QNNPACK=OFF ENV USE_NNPACK=OFF ENV USE_KINETO=OFF ENV USE_OPENMP=OFF ENV USE_TENSORPIPE=OFF ENV ROCM_PATH=/usr -ENV MAX_JOBS=12 ENV DEVICE_LIB_PATH=/usr/lib/llvm-21/lib/clang/21/amdgcn/bitcode ENV HIPFLAGS="--rocm-device-lib-path=$DEVICE_LIB_PATH" ENV CMAKE_ARGS="-DCMAKE_HIP_COMPILER_WORKS=1 \ @@ -107,9 +139,24 @@ RUN git clone https://github.com/pytorch/pytorch.git && \ ln -s /usr/lib/llvm-21/bin/clang++ /usr/bin/clang++ \ python3 setup.py build && \ python3 setup.py install + # Failing + +# Build pytorch-audio +FROM pytorch AS torchaudio +WORKDIR /build/torchaudio + +# Build pytorch-vision +FROM torchaudio AS torchvision +WORKDIR /build/torchaudio +RUN git clone https://github.com/pytorch/vision.git + +# Build final stripped down image +FROM ubuntu:26.04 as rocm-aarch64 +# Copy in rocm, pytorch, torchaudio, torchvision -# Build ComfyUI + +# Move to a new image | Build ComfyUI FROM pytorch AS comfyui WORKDIR /app RUN git clone https://github.com/comfyanonymous/ComfyUI.git .