fix: use cmake -B to override preset binaryDir, cmake --build/--install use explicit path

This commit is contained in:
2026-05-09 23:52:46 -04:00
parent 208bfd4612
commit bf2f17c5e2

View File

@@ -45,12 +45,12 @@ ENV LDFLAGS=-s
# Pre-set CMAKE_HIP_COMPILER="" to prevent check_language(HIP) from
# finding a HIP compiler (it searches /opt/rocm even without PATH).
# Remove /opt/rocm from PATH to prevent find_program from finding hipcc.
RUN mkdir -p build-cpu && cd build-cpu && \
RUN mkdir -p build-cpu && \
PATH=/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
cmake .. -DCMAKE_BUILD_TYPE=Release \
cmake -B build-cpu -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_HIP_COMPILER="" && \
cmake --build . --target ggml-cpu -- -l $(nproc) && \
cmake --install . --component CPU --strip --prefix /build/dist
cmake --build build-cpu --target ggml-cpu -- -l $(nproc) && \
cmake --install build-cpu --component CPU --strip --prefix /build/dist
# Step 2: Build HIP backend with ROCm preset + gfx906 target only
# The ROCm 6 preset enables HIP language detection (enable_language(HIP))
@@ -58,14 +58,14 @@ RUN mkdir -p build-cpu && cd build-cpu && \
# OLLAMA_RUNNER_DIR=rocm from the preset, so HIP goes to lib/ollama/rocm/
# Need CMAKE_PREFIX_PATH so find_package(hip) finds hip-config.cmake
# at /opt/rocm/lib/cmake/hip/hip-config.cmake.
RUN mkdir -p build-hip && cd build-hip && \
cmake .. \
RUN mkdir -p build-hip && \
cmake -B build-hip \
--preset 'ROCm 6' \
-DAMDGPU_TARGETS="gfx906:xnack-" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="/opt/rocm" && \
cmake --build . --target ggml-hip -- -l $(nproc) && \
cmake --install . --component HIP --strip --prefix /build/dist && \
cmake --build build-hip --target ggml-hip -- -l $(nproc) && \
cmake --install build-hip --component HIP --strip --prefix /build/dist && \
echo "=== HIP install ===" && \
find /build/dist/lib/ollama -type f -o -type l | head -20