Updating toolboxes with a two-stage build process to reduce size
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
FROM fedora:rawhide
|
||||
# build stage
|
||||
FROM registry.fedoraproject.org/fedora:rawhide AS builder
|
||||
|
||||
# getting Rocm7 repos
|
||||
RUN <<EOF
|
||||
# rocm 7.0 repos
|
||||
RUN <<'EOF'
|
||||
tee /etc/yum.repos.d/rocm.repo <<REPO
|
||||
[ROCm-7.0.0]
|
||||
name=ROCm7.0.0
|
||||
@@ -21,49 +22,92 @@ priority=50
|
||||
gpgcheck=1
|
||||
gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key
|
||||
REPO
|
||||
|
||||
EOF
|
||||
|
||||
# Install build dependencies and tools
|
||||
RUN dnf install -y \
|
||||
# deps
|
||||
RUN dnf -y --nodocs --setopt=install_weak_deps=False install \
|
||||
make gcc cmake lld clang clang-devel compiler-rt libcurl-devel \
|
||||
rocm rocminfo radeontop \
|
||||
git vim \
|
||||
&& dnf clean all
|
||||
&& 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
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
# Ensure we are using hipblaslt
|
||||
|
||||
# runtime stage
|
||||
FROM registry.fedoraproject.org/fedora-minimal:rawhide
|
||||
|
||||
# rocm 7.0 repos
|
||||
RUN <<'EOF'
|
||||
tee /etc/yum.repos.d/rocm.repo <<REPO
|
||||
[ROCm-7.0.0]
|
||||
name=ROCm7.0.0
|
||||
baseurl=https://repo.radeon.com/rocm/el9/7.0_beta/main
|
||||
enabled=1
|
||||
priority=50
|
||||
gpgcheck=1
|
||||
gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key
|
||||
REPO
|
||||
|
||||
tee /etc/yum.repos.d/rocm-graphics.repo <<REPO
|
||||
[ROCm-7.0.0-Graphics]
|
||||
name=ROCm7.0.0-Graphics
|
||||
baseurl=https://repo.radeon.com/graphics/7.0_beta/rhel/9/main/x86_64/
|
||||
enabled=1
|
||||
priority=50
|
||||
gpgcheck=1
|
||||
gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key
|
||||
REPO
|
||||
EOF
|
||||
|
||||
# runtime deps
|
||||
RUN microdnf -y --nodocs --setopt=install_weak_deps=0 install \
|
||||
bash ca-certificates libatomic libstdc++ libgcc \
|
||||
rocm rocminfo 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
|
||||
|
||||
# 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"]
|
||||
|
||||
Reference in New Issue
Block a user