114 lines
2.9 KiB
Docker
114 lines
2.9 KiB
Docker
# build stage
|
|
FROM registry.fedoraproject.org/fedora:rawhide AS builder
|
|
|
|
# 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
|
|
|
|
# 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 && rm -rf /var/cache/dnf/*
|
|
|
|
# llama.cpp
|
|
WORKDIR /opt/llama.cpp
|
|
RUN git clone --recursive https://github.com/ggerganov/llama.cpp.git .
|
|
|
|
# build
|
|
RUN git clean -xdf \
|
|
&& 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
|
|
|
|
|
|
# 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 \
|
|
&& echo 'source /etc/profile.d/rocm.sh' >> /etc/bashrc
|
|
|
|
# shell
|
|
CMD ["/bin/bash"]
|