From f0aac524d3f29140e60ba78f3cfb16d6acea87db Mon Sep 17 00:00:00 2001 From: leejet Date: Sat, 17 Oct 2026 14:14:29 +0800 Subject: [PATCH] ci: align MUSA Docker image with upstream SDK 5.2.0 and mp_31 --- docker/Dockerfile.musa | 11 +++++------ docs/build.md | 6 ++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile.musa b/docker/Dockerfile.musa index 7dda431a..08d6f1d4 100644 --- a/docker/Dockerfile.musa +++ b/docker/Dockerfile.musa @@ -1,7 +1,6 @@ -ARG MUSA_VERSION=rc4.2.0 -ARG UBUNTU_VERSION=22.04 +ARG MUSA_IMAGE=registry.mthreads.com/mcconline/inference/pytorch:2.9.1.post1-py3.10-musa5.2.0-mp31-devel-ubuntu22.04-amd64 -FROM mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}-amd64 as build +FROM ${MUSA_IMAGE} AS build # sd-server embeds the web UI at build time, so the build image needs Node/pnpm. RUN apt-get update && apt-get install -y --no-install-recommends ccache cmake git ca-certificates curl gnupg && \ @@ -22,9 +21,8 @@ COPY . . RUN mkdir build && cd build && \ cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ - -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -fopenmp -I/usr/lib/llvm-14/lib/clang/14.0.0/include -L/usr/lib/llvm-14/lib" \ - -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fopenmp -I/usr/lib/llvm-14/lib/clang/14.0.0/include -L/usr/lib/llvm-14/lib" \ -DSD_MUSA=ON \ + -DMUSA_ARCHITECTURES=31 \ -DSD_BUILD_SHARED_LIBS=ON \ -DGGML_NATIVE=OFF \ -DSD_BUILD_SHARED_GGML_LIB=ON \ @@ -35,7 +33,7 @@ RUN mkdir build && cd build && \ -DCMAKE_BUILD_TYPE=Release && \ cmake --build . --config Release -FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}-amd64 as runtime +FROM ${MUSA_IMAGE} AS runtime COPY --from=build /sd.cpp/build/bin /sd.cpp/bin RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \ @@ -45,3 +43,4 @@ RUN printf '#!/bin/sh\nexec /sd.cpp/bin/sd-cli "$@"\n' > /sd-cli && \ WORKDIR /sd.cpp ENTRYPOINT [ "/sd-cli" ] +CMD [] diff --git a/docs/build.md b/docs/build.md index 9daaa219..6ec0e40f 100644 --- a/docs/build.md +++ b/docs/build.md @@ -119,14 +119,16 @@ cmake --build . --config Release ## Build with MUSA -This provides GPU acceleration using Moore Threads GPU. Make sure to have the MUSA toolkit installed. +This provides GPU acceleration using Moore Threads GPUs. The configuration below follows upstream validation with MUSA SDK 5.2.0 and MTT S5000 (PH1, `mp_31`). Install that toolkit before building. Older SDKs such as 4.2 may lack the CUB headers required by the current backend. ```shell mkdir build && cd build -cmake .. -DCMAKE_C_COMPILER=/usr/local/musa/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/musa/bin/clang++ -DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release +cmake .. -DCMAKE_C_COMPILER=/usr/local/musa/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/musa/bin/clang++ -DSD_MUSA=ON -DMUSA_ARCHITECTURES=31 -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release ``` +The MUSA Docker image uses the same SDK 5.2.0 development image as upstream for both build and runtime stages, and targets `mp_31` only. It includes the development tools and PyTorch from that base image, so it is larger than a minimal runtime image. Other GPU architectures require separate validation. + ## Build with Metal Using Metal makes the computation run on the GPU. Currently, there are some issues with Metal when performing operations on very large matrices, making it highly inefficient at the moment. Performance improvements are expected in the near future.