Files
amd-strix-halo-toolboxes/toolboxes/Dockerfile.rocm-7rc
T
2025-08-06 09:09:01 +01:00

81 lines
2.9 KiB
Docker

FROM fedora:rawhide
# 1) Install dependencies
RUN dnf install -y \
make gcc cmake lld clang clang-devel compiler-rt libcurl-devel \
radeontop git vim patch curl \
&& dnf clean all
# 2) Download ROCm nightly tarball
WORKDIR /tmp
RUN curl -L -o therock.tar.gz \
https://github.com/ROCm/TheRock/releases/download/nightly-tarball/therock-dist-linux-gfx1151-7.0.0rc20250714.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
# 4) Bake in ROCm env + full system PATH
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
# 5) (Optional) profile.d snippet for login & interactive shells
RUN tee /etc/profile.d/rocm.sh << 'EOF'
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"
EOF
RUN 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 \
&& 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
# 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
CMD ["/bin/bash"]