From ca0800bd0167f8c12250b019036a8bca6c9ded5a Mon Sep 17 00:00:00 2001 From: Donato Capitella Date: Sat, 16 Aug 2025 10:21:59 +0100 Subject: [PATCH] Updating toolboxes with a two-stage build process to reduce size --- toolboxes/Dockerfile.rocm-6.4.2 | 66 +++++++++++------ toolboxes/Dockerfile.rocm-6.4.2-rocwmma | 72 +++++++++++------- toolboxes/Dockerfile.rocm-6.4.3 | 98 +++++++++++++++++-------- toolboxes/Dockerfile.rocm-6.4.3-rocwmma | 96 ++++++++++++++++-------- toolboxes/Dockerfile.rocm-7beta | 98 ++++++++++++++++++------- toolboxes/Dockerfile.rocm-7rc | 80 ++++++++++++++------ toolboxes/Dockerfile.rocm-7rc-rocwmma | 92 +++++++++++++++-------- toolboxes/Dockerfile.vulkan-amdvlk | 56 +++++++++++--- toolboxes/Dockerfile.vulkan-radv | 43 +++++++++-- 9 files changed, 492 insertions(+), 209 deletions(-) diff --git a/toolboxes/Dockerfile.rocm-6.4.2 b/toolboxes/Dockerfile.rocm-6.4.2 index 75e7c06..3232c30 100644 --- a/toolboxes/Dockerfile.rocm-6.4.2 +++ b/toolboxes/Dockerfile.rocm-6.4.2 @@ -1,38 +1,58 @@ -FROM fedora:rawhide +# build +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# Install build dependencies and tools -RUN dnf install -y \ +# deps + rocm toolchain +RUN dnf -y --nodocs --setopt=install_weak_deps=False install \ make gcc cmake lld clang clang-devel compiler-rt libcurl-devel \ - rocminfo radeontop 'rocm-*' 'rocblas-*' 'hipblas' 'hipblas-*' \ - git vim \ - && dnf clean all + rocminfo radeontop 'rocm-*' 'rocblas-*' hipblas 'hipblas-*' \ + git vim rsync sudo tar xz \ + && dnf clean all && rm -rf /var/cache/dnf/* -# Set up working directory +# llama.cpp WORKDIR /opt/llama.cpp - -# Clone llama.cpp repository (with submodules) RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git . -# Build llama.cpp with HIP support +# build + install RUN git clean -xdf \ - && git pull \ - && git submodule update --recursive \ - && \ - # Configure and compile with HIP toolchain - HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \ - cmake -S . -B build \ - -DGGML_HIP=ON \ - -DAMDGPU_TARGETS=gfx1151 \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLAMA_HIP_UMA=ON \ - && cmake --build build --config Release -- -j$(nproc) \ - && cmake --install build --config Release + && git pull \ + && git submodule update --recursive \ + && HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \ + cmake -S . -B build \ + -DGGML_HIP=ON \ + -DAMDGPU_TARGETS=gfx1151 \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLAMA_HIP_UMA=ON \ + && cmake --build build --config Release -- -j$(nproc) \ + && cmake --install build --config Release +# make ld see libllama in builder too (kept same step) RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ && ldconfig + +# runtime +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +# runtime deps (same rocm packages; no build toolchain) +RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \ + bash ca-certificates libatomic libstdc++ libgcc \ + rocminfo radeontop 'rocm-*' 'rocblas-*' hipblas 'hipblas-*' \ + && microdnf clean all && rm -rf /var/cache/dnf/* + +# bits from builder +COPY --from=builder /usr/local/ /usr/local/ +COPY --from=builder /usr/include/rocwmma /usr/include/rocwmma + +# ensure libllama is on the linker path +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -# Default to interactive shell +# shell CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.rocm-6.4.2-rocwmma b/toolboxes/Dockerfile.rocm-6.4.2-rocwmma index 5e90b4d..7068e0a 100644 --- a/toolboxes/Dockerfile.rocm-6.4.2-rocwmma +++ b/toolboxes/Dockerfile.rocm-6.4.2-rocwmma @@ -1,45 +1,65 @@ -FROM fedora:rawhide +# build +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# Install build dependencies and tools -RUN dnf install -y \ +# deps + rocm toolchain +RUN dnf -y --nodocs --setopt=install_weak_deps=False install \ make gcc cmake lld clang clang-devel compiler-rt libcurl-devel \ - rocminfo radeontop 'rocm-*' 'rocblas-*' 'hipblas' 'hipblas-*' \ - git vim rsync \ - && dnf clean all + rocminfo radeontop 'rocm-*' 'rocblas-*' hipblas 'hipblas-*' \ + git vim rsync sudo tar xz \ + && dnf clean all && rm -rf /var/cache/dnf/* - -WORKDIR /opt/ +# rocWMMA headers +WORKDIR /opt RUN git clone -b release/rocm-rel-7.0 https://github.com/ROCm/rocWMMA.git RUN sudo mkdir -p /usr/include/rocwmma RUN sudo rsync -a rocWMMA/library/include/rocwmma/ /usr/include/rocwmma/ -# Set up working directory +# llama.cpp WORKDIR /opt/llama.cpp - -# Clone llama.cpp repository (with submodules) RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git . -# Build llama.cpp with HIP support +# build + install RUN git clean -xdf \ - && git pull \ - && git submodule update --recursive \ - && \ - # Configure and compile with HIP toolchain - HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \ - cmake -S . -B build \ - -DGGML_HIP=ON \ - -DAMDGPU_TARGETS=gfx1151 \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLAMA_HIP_UMA=ON \ - -DGGML_HIP_ROCWMMA_FATTN=ON \ - && cmake --build build --config Release -- -j$(nproc) \ - && cmake --install build --config Release + && git pull \ + && git submodule update --recursive \ + && HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \ + cmake -S . -B build \ + -DGGML_HIP=ON \ + -DAMDGPU_TARGETS=gfx1151 \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLAMA_HIP_UMA=ON \ + -DGGML_HIP_ROCWMMA_FATTN=ON \ + && cmake --build build --config Release -- -j$(nproc) \ + && cmake --install build --config Release +# make ld see libllama in builder too (kept same step) RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ && ldconfig + +# runtime +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +# runtime deps (same rocm packages; no build toolchain) +RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \ + bash ca-certificates libatomic libstdc++ libgcc \ + rocminfo radeontop 'rocm-*' 'rocblas-*' hipblas 'hipblas-*' \ + && microdnf clean all && rm -rf /var/cache/dnf/* + +# bits from builder +COPY --from=builder /usr/local/ /usr/local/ +COPY --from=builder /usr/include/rocwmma /usr/include/rocwmma + +# ensure libllama is on the linker path +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -# Default to interactive shell +# shell CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.rocm-6.4.3 b/toolboxes/Dockerfile.rocm-6.4.3 index d163382..c19d136 100644 --- a/toolboxes/Dockerfile.rocm-6.4.3 +++ b/toolboxes/Dockerfile.rocm-6.4.3 @@ -1,7 +1,8 @@ -FROM fedora:rawhide +# build stage +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# getting Rocm6.4.3 repos -RUN < /etc/profile.d/rocm.sh \ - && chmod +x /etc/profile.d/rocm.sh \ - && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc - +# helper COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -# Default to interactive shell + +# runtime stage +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +# rocm 6.4.3 repo +RUN <<'EOF' +tee /etc/yum.repos.d/rocm.repo < /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper +COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py +RUN chmod +x /usr/local/bin/gguf-vram-estimator.py + +# profile +RUN printf '%s\n' \ + 'export ROCBLAS_USE_HIPBLASLT=1' \ + > /etc/profile.d/rocm.sh && chmod +x /etc/profile.d/rocm.sh \ + && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc + +# shell CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.rocm-6.4.3-rocwmma b/toolboxes/Dockerfile.rocm-6.4.3-rocwmma index 15512a1..a8020a6 100644 --- a/toolboxes/Dockerfile.rocm-6.4.3-rocwmma +++ b/toolboxes/Dockerfile.rocm-6.4.3-rocwmma @@ -1,7 +1,8 @@ -FROM fedora:rawhide +# build stage +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# getting Rocm6.4.3 repos -RUN < /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper +COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py +RUN chmod +x /usr/local/bin/gguf-vram-estimator.py + +# profile RUN printf '%s\n' \ 'export ROCBLAS_USE_HIPBLASLT=1' \ - > /etc/profile.d/rocm.sh \ - && chmod +x /etc/profile.d/rocm.sh \ + > /etc/profile.d/rocm.sh && chmod +x /etc/profile.d/rocm.sh \ && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc -# Default to interactive shell +# shell CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.rocm-7beta b/toolboxes/Dockerfile.rocm-7beta index 8936886..6f02f93 100644 --- a/toolboxes/Dockerfile.rocm-7beta +++ b/toolboxes/Dockerfile.rocm-7beta @@ -1,7 +1,8 @@ -FROM fedora:rawhide +# build stage +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# getting Rocm7 repos -RUN < /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper +COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py +RUN chmod +x /usr/local/bin/gguf-vram-estimator.py + +# profile RUN printf '%s\n' \ 'export ROCBLAS_USE_HIPBLASLT=1' \ - > /etc/profile.d/rocm.sh \ - && chmod +x /etc/profile.d/rocm.sh \ + > /etc/profile.d/rocm.sh && chmod +x /etc/profile.d/rocm.sh \ && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc -# Default to interactive shell +# shell CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.rocm-7rc b/toolboxes/Dockerfile.rocm-7rc index 139337e..5434798 100644 --- a/toolboxes/Dockerfile.rocm-7rc +++ b/toolboxes/Dockerfile.rocm-7rc @@ -1,21 +1,17 @@ -FROM fedora:rawhide +# build +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# 1) Install dependencies -RUN dnf install -y \ +RUN dnf -y --nodocs --setopt=install_weak_deps=False install \ make gcc cmake lld clang clang-devel compiler-rt libcurl-devel \ - radeontop git vim patch curl \ - && dnf clean all + radeontop git vim patch curl ninja-build tar xz \ + && dnf clean all && rm -rf /var/cache/dnf/* -# 2) Download ROCm nightly tarball WORKDIR /tmp RUN curl -L -o therock.tar.gz \ https://therock-nightly-tarball.s3.amazonaws.com/therock-dist-linux-gfx1151-7.0.0rc20250811.tar.gz - -# 3) Extract into /opt/rocm-7.0 RUN mkdir -p /opt/rocm-7.0 \ - && tar xvf therock.tar.gz -C /opt/rocm-7.0 --strip-components=1 + && tar xzf therock.tar.gz -C /opt/rocm-7.0 --strip-components=1 -# 4) Bake in ROCm env + full system PATH ENV ROCM_PATH=/opt/rocm-7.0 \ HIP_PLATFORM=amd \ HIP_PATH=/opt/rocm-7.0 \ @@ -29,7 +25,6 @@ ENV ROCM_PATH=/opt/rocm-7.0 \ CPATH=/opt/rocm-7.0/include \ PKG_CONFIG_PATH=/opt/rocm-7.0/lib/pkgconfig -# 5) profile.d snippet for login & interactive shells RUN printf '%s\n' \ 'export ROCM_PATH=/opt/rocm-7.0' \ 'export HIP_PLATFORM=amd' \ @@ -48,32 +43,73 @@ RUN printf '%s\n' \ && chmod +x /etc/profile.d/rocm.sh \ && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc -# 6) Clone llama.cpp WORKDIR /opt/llama.cpp RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git . \ && git clean -xdf \ && git submodule update --recursive -# 7) Copy in your external patch and apply -COPY hip-rocm7rc.patch /opt/llama.cpp/hip-rocm7rc.patch -RUN patch -p1 < hip-rocm7rc.patch - -# 8) Configure, build & install llama.cpp with HIP RUN cmake -S . -B build \ -DGGML_HIP=ON \ -DAMDGPU_TARGETS=gfx1151 \ -DCMAKE_BUILD_TYPE=Release \ -DLLAMA_HIP_UMA=ON \ + -DGGML_HIP_ROCWMMA_FATTN=ON \ && cmake --build build --config Release -- -j$(nproc) \ && cmake --install build --config Release -# 9) Copy the .so from build/bin into /usr/lib64 so ldconfig can see it -RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ - && ldconfig +# keep bin; drop headers/docs/static libs; drop source tree +RUN find /opt/rocm-7.0 -type f -name '*.a' -delete \ + && rm -rf /opt/rocm-7.0/include /opt/rocm-7.0/share \ + /opt/rocm-7.0/llvm/include /opt/rocm-7.0/llvm/share \ + && rm -rf /opt/llama.cpp + +# runtime +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \ + bash ca-certificates libatomic libstdc++ libgcc radeontop vim \ + && microdnf clean all && rm -rf /var/cache/dnf/* + +COPY --from=builder /opt/rocm-7.0 /opt/rocm-7.0 +COPY --from=builder /usr/local/ /usr/local/ -# 10) Install helper script COPY gguf-vram-estimator.py /usr/local/bin/ RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -# 11) Default to interactive bash +ENV ROCM_PATH=/opt/rocm-7.0 \ + HIP_PLATFORM=amd \ + HIP_PATH=/opt/rocm-7.0 \ + HIP_CLANG_PATH=/opt/rocm-7.0/llvm/bin \ + HIP_INCLUDE_PATH=/opt/rocm-7.0/include \ + HIP_LIB_PATH=/opt/rocm-7.0/lib \ + HIP_DEVICE_LIB_PATH=/opt/rocm-7.0/lib/llvm/amdgcn/bitcode \ + PATH=/opt/rocm-7.0/bin:/opt/rocm-7.0/llvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ + LD_LIBRARY_PATH=/opt/rocm-7.0/lib:/opt/rocm-7.0/lib64:/opt/rocm-7.0/llvm/lib \ + LIBRARY_PATH=/opt/rocm-7.0/lib:/opt/rocm-7.0/lib64 \ + CPATH=/opt/rocm-7.0/include \ + PKG_CONFIG_PATH=/opt/rocm-7.0/lib/pkgconfig + +RUN printf '%s\n' \ + 'export ROCM_PATH=/opt/rocm-7.0' \ + 'export HIP_PLATFORM=amd' \ + 'export HIP_PATH=/opt/rocm-7.0' \ + 'export HIP_CLANG_PATH=/opt/rocm-7.0/llvm/bin' \ + 'export HIP_INCLUDE_PATH=/opt/rocm-7.0/include' \ + 'export HIP_LIB_PATH=/opt/rocm-7.0/lib' \ + 'export HIP_DEVICE_LIB_PATH=/opt/rocm-7.0/lib/llvm/amdgcn/bitcode' \ + 'export PATH="$ROCM_PATH/bin:$HIP_CLANG_PATH:$PATH"' \ + 'export LD_LIBRARY_PATH="$HIP_LIB_PATH:$ROCM_PATH/lib:$ROCM_PATH/lib64:$ROCM_PATH/llvm/lib"' \ + 'export LIBRARY_PATH="$HIP_LIB_PATH:$ROCM_PATH/lib:$ROCM_PATH/lib64"' \ + 'export CPATH="$HIP_INCLUDE_PATH"' \ + 'export PKG_CONFIG_PATH="$ROCM_PATH/lib/pkgconfig"' \ + 'export ROCBLAS_USE_HIPBLASLT=1' \ + > /etc/profile.d/rocm.sh \ + && chmod +x /etc/profile.d/rocm.sh \ + && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc + +# make /usr/local libs visible without touching env +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig + CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.rocm-7rc-rocwmma b/toolboxes/Dockerfile.rocm-7rc-rocwmma index 137053f..ff833fc 100644 --- a/toolboxes/Dockerfile.rocm-7rc-rocwmma +++ b/toolboxes/Dockerfile.rocm-7rc-rocwmma @@ -1,21 +1,17 @@ -FROM fedora:rawhide +# build +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# 1) Install dependencies -RUN dnf install -y \ +RUN dnf -y --nodocs --setopt=install_weak_deps=False install \ make gcc cmake lld clang clang-devel compiler-rt libcurl-devel \ - radeontop git vim patch curl ninja-build \ - && dnf clean all + radeontop git vim patch curl ninja-build tar xz \ + && dnf clean all && rm -rf /var/cache/dnf/* -# 2) Download ROCm nightly tarball WORKDIR /tmp RUN curl -L -o therock.tar.gz \ https://therock-nightly-tarball.s3.amazonaws.com/therock-dist-linux-gfx1151-7.0.0rc20250811.tar.gz - -# 3) Extract into /opt/rocm-7.0 RUN mkdir -p /opt/rocm-7.0 \ - && tar xvf therock.tar.gz -C /opt/rocm-7.0 --strip-components=1 + && tar xzf therock.tar.gz -C /opt/rocm-7.0 --strip-components=1 -# 4) Bake in ROCm env + full system PATH ENV ROCM_PATH=/opt/rocm-7.0 \ HIP_PLATFORM=amd \ HIP_PATH=/opt/rocm-7.0 \ @@ -29,7 +25,6 @@ ENV ROCM_PATH=/opt/rocm-7.0 \ CPATH=/opt/rocm-7.0/include \ PKG_CONFIG_PATH=/opt/rocm-7.0/lib/pkgconfig -# 5) profile.d snippet for login & interactive shells RUN printf '%s\n' \ 'export ROCM_PATH=/opt/rocm-7.0' \ 'export HIP_PLATFORM=amd' \ @@ -48,28 +43,17 @@ RUN printf '%s\n' \ && chmod +x /etc/profile.d/rocm.sh \ && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc -# Install rocwmma -WORKDIR /opt/ +WORKDIR /opt COPY ./build-rocwmma.sh . -RUN chmod +x build-rocwmma.sh -RUN ./build-rocwmma.sh +RUN chmod +x build-rocwmma.sh && ./build-rocwmma.sh -# 6) Clone llama.cpp WORKDIR /opt/llama.cpp RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git . \ && git clean -xdf \ && git submodule update --recursive +COPY ./apply-rocwmma-fix.sh /opt/apply-rocwmma-fix.sh +RUN chmod +x /opt/apply-rocwmma-fix.sh && /opt/apply-rocwmma-fix.sh /opt/llama.cpp -# Apply PAtch for rocwmma -COPY ./apply-rocwmma-fix.sh /opt -RUN chmod +x /opt/apply-rocwmma-fix.sh -RUN /opt/apply-rocwmma-fix.sh /opt/llama.cpp - -# 7) Apply patchpatch and apply -COPY hip-rocm7rc.patch /opt/llama.cpp/hip-rocm7rc.patch -RUN patch -p1 < hip-rocm7rc.patch - -# 8) Configure, build & install llama.cpp with HIP RUN cmake -S . -B build \ -DGGML_HIP=ON \ -DAMDGPU_TARGETS=gfx1151 \ @@ -79,13 +63,59 @@ RUN cmake -S . -B build \ && cmake --build build --config Release -- -j$(nproc) \ && cmake --install build --config Release -# 9) Copy the .so from build/bin into /usr/lib64 so ldconfig can see it -RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ - && ldconfig +# keep bin; drop headers/docs/static libs; drop source tree +RUN find /opt/rocm-7.0 -type f -name '*.a' -delete \ + && rm -rf /opt/rocm-7.0/include /opt/rocm-7.0/share \ + /opt/rocm-7.0/llvm/include /opt/rocm-7.0/llvm/share \ + && rm -rf /opt/llama.cpp + +# runtime +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \ + bash ca-certificates libatomic libstdc++ libgcc radeontop vim \ + && microdnf clean all && rm -rf /var/cache/dnf/* + +COPY --from=builder /opt/rocm-7.0 /opt/rocm-7.0 +COPY --from=builder /usr/local/ /usr/local/ -# 10) Install helper script COPY gguf-vram-estimator.py /usr/local/bin/ RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -# 11) Default to interactive bash +ENV ROCM_PATH=/opt/rocm-7.0 \ + HIP_PLATFORM=amd \ + HIP_PATH=/opt/rocm-7.0 \ + HIP_CLANG_PATH=/opt/rocm-7.0/llvm/bin \ + HIP_INCLUDE_PATH=/opt/rocm-7.0/include \ + HIP_LIB_PATH=/opt/rocm-7.0/lib \ + HIP_DEVICE_LIB_PATH=/opt/rocm-7.0/lib/llvm/amdgcn/bitcode \ + PATH=/opt/rocm-7.0/bin:/opt/rocm-7.0/llvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ + LD_LIBRARY_PATH=/opt/rocm-7.0/lib:/opt/rocm-7.0/lib64:/opt/rocm-7.0/llvm/lib \ + LIBRARY_PATH=/opt/rocm-7.0/lib:/opt/rocm-7.0/lib64 \ + CPATH=/opt/rocm-7.0/include \ + PKG_CONFIG_PATH=/opt/rocm-7.0/lib/pkgconfig + +RUN printf '%s\n' \ + 'export ROCM_PATH=/opt/rocm-7.0' \ + 'export HIP_PLATFORM=amd' \ + 'export HIP_PATH=/opt/rocm-7.0' \ + 'export HIP_CLANG_PATH=/opt/rocm-7.0/llvm/bin' \ + 'export HIP_INCLUDE_PATH=/opt/rocm-7.0/include' \ + 'export HIP_LIB_PATH=/opt/rocm-7.0/lib' \ + 'export HIP_DEVICE_LIB_PATH=/opt/rocm-7.0/lib/llvm/amdgcn/bitcode' \ + 'export PATH="$ROCM_PATH/bin:$HIP_CLANG_PATH:$PATH"' \ + 'export LD_LIBRARY_PATH="$HIP_LIB_PATH:$ROCM_PATH/lib:$ROCM_PATH/lib64:$ROCM_PATH/llvm/lib"' \ + 'export LIBRARY_PATH="$HIP_LIB_PATH:$ROCM_PATH/lib:$ROCM_PATH/lib64"' \ + 'export CPATH="$HIP_INCLUDE_PATH"' \ + 'export PKG_CONFIG_PATH="$ROCM_PATH/lib/pkgconfig"' \ + 'export ROCBLAS_USE_HIPBLASLT=1' \ + > /etc/profile.d/rocm.sh \ + && chmod +x /etc/profile.d/rocm.sh \ + && echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc + +# make /usr/local libs visible without touching env +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig + CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.vulkan-amdvlk b/toolboxes/Dockerfile.vulkan-amdvlk index facd6da..ae6a99a 100644 --- a/toolboxes/Dockerfile.vulkan-amdvlk +++ b/toolboxes/Dockerfile.vulkan-amdvlk @@ -1,24 +1,25 @@ -FROM fedora:rawhide +# build stage +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# Install build tools, Vulkan headers/loader, and glslc -RUN dnf install --refresh -y \ +# deps +RUN dnf -y --nodocs --setopt=install_weak_deps=False install \ git vim \ make gcc cmake ninja-build lld clang clang-devel compiler-rt libcurl-devel \ vulkan-loader-devel vulkaninfo mesa-vulkan-drivers \ radeontop glslc wget \ - && dnf clean all + && dnf clean all && rm -rf /var/cache/dnf/* -# Get AMDVLK drivers +# amdvlk RUN curl -L -o /tmp/amdvlk-2025.Q2.1.x86_64.rpm \ - https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2025.Q2.1/amdvlk-2025.Q2.1.x86_64.rpm -RUN dnf install -y /tmp/amdvlk-*.rpm + https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2025.Q2.1/amdvlk-2025.Q2.1.x86_64.rpm \ + && dnf -y install /tmp/amdvlk-*.rpm \ + && rm -f /tmp/amdvlk-*.rpm +# llama.cpp WORKDIR /opt/llama.cpp - -# Clone llama.cpp RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git . -# Build with Vulkan support +# build RUN git clean -xdf \ && git pull \ && git submodule update --recursive \ @@ -32,10 +33,43 @@ RUN git clean -xdf \ && cmake --build build --config Release \ && cmake --install build --config Release +# libs RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ && ldconfig +# helper COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -CMD ["/bin/bash"] \ No newline at end of file + +# runtime stage +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +# runtime deps +RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \ + bash ca-certificates libatomic libstdc++ libgcc \ + vulkan-loader vulkan-loader-devel vulkaninfo mesa-vulkan-drivers radeontop \ + && microdnf clean all && rm -rf /var/cache/dnf/* + +# amdvlk +RUN curl -L -o /tmp/amdvlk-2025.Q2.1.x86_64.rpm \ + https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2025.Q2.1/amdvlk-2025.Q2.1.x86_64.rpm \ + && microdnf -y install /tmp/amdvlk-*.rpm \ + && rm -f /tmp/amdvlk-*.rpm + +# copy +COPY --from=builder /usr/local/ /usr/local/ + +# ld +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper +COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py +RUN chmod +x /usr/local/bin/gguf-vram-estimator.py + +# shell +CMD ["/bin/bash"] diff --git a/toolboxes/Dockerfile.vulkan-radv b/toolboxes/Dockerfile.vulkan-radv index 09a568a..e834bc3 100644 --- a/toolboxes/Dockerfile.vulkan-radv +++ b/toolboxes/Dockerfile.vulkan-radv @@ -1,19 +1,19 @@ -FROM fedora:rawhide +# build stage +FROM registry.fedoraproject.org/fedora:rawhide AS builder -# Install build tools, Vulkan headers/loader, and glslc -RUN dnf install --refresh -y \ +# deps +RUN dnf -y --nodocs --setopt=install_weak_deps=False install \ git vim \ make gcc cmake ninja-build lld clang clang-devel compiler-rt libcurl-devel \ vulkan-loader-devel vulkaninfo mesa-vulkan-drivers \ radeontop glslc \ - && dnf clean all + && dnf clean all && rm -rf /var/cache/dnf/* +# llama.cpp WORKDIR /opt/llama.cpp - -# Clone llama.cpp RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git . -# Build with Vulkan support +# build RUN git clean -xdf \ && git pull \ && git submodule update --recursive \ @@ -27,10 +27,37 @@ RUN git clean -xdf \ && cmake --build build --config Release \ && cmake --install build --config Release +# libs RUN find /opt/llama.cpp/build -type f -name 'lib*.so*' -exec cp {} /usr/lib64/ \; \ && ldconfig +# helper COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py RUN chmod +x /usr/local/bin/gguf-vram-estimator.py -CMD ["/bin/bash"] \ No newline at end of file + +# runtime stage +FROM registry.fedoraproject.org/fedora-minimal:rawhide + +# runtime deps +RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \ + bash ca-certificates libatomic libstdc++ libgcc \ + vulkan-loader vulkan-loader-devel vulkaninfo mesa-vulkan-drivers radeontop \ + && microdnf clean all && rm -rf /var/cache/dnf/* + +# copy +COPY --from=builder /usr/local/ /usr/local/ + +# ld +RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf \ + && echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local.conf \ + && ldconfig \ + && cp -n /usr/local/lib/libllama*.so* /usr/lib64/ 2>/dev/null || true \ + && ldconfig + +# helper +COPY gguf-vram-estimator.py /usr/local/bin/gguf-vram-estimator.py +RUN chmod +x /usr/local/bin/gguf-vram-estimator.py + +# shell +CMD ["/bin/bash"]