Skip to content

Commit

Permalink
feat: support Moore Threads GPU (leejet#529)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaodong Ye <[email protected]>
  • Loading branch information
yeahdongcn authored and Stéphane du Hamel committed Dec 28, 2024
1 parent 9a812fd commit ec3912b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ option(SD_HIPBLAS "sd: rocm backend" OFF)
option(SD_METAL "sd: metal backend" OFF)
option(SD_VULKAN "sd: vulkan backend" OFF)
option(SD_SYCL "sd: sycl backend" OFF)
option(SD_MUSA "sd: musa backend" OFF)
option(SD_FAST_SOFTMAX "sd: x1.5 faster softmax, indeterministic (sometimes, same seed don't generate same image), cuda only" OFF)
option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF)
#option(SD_BUILD_SERVER "sd: build server example" ON)
Expand Down Expand Up @@ -60,9 +61,18 @@ if (SD_HIPBLAS)
endif()
endif ()

if(SD_MUSA)
message("-- Use MUSA as backend stable-diffusion")
set(GGML_MUSA ON)
add_definitions(-DSD_USE_CUBLAS)
if(SD_FAST_SOFTMAX)
set(GGML_CUDA_FAST_SOFTMAX ON)
endif()
endif()

set(SD_LIB stable-diffusion)

file(GLOB SD_LIB_SOURCES
file(GLOB SD_LIB_SOURCES
"*.h"
"*.cpp"
"*.hpp"
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile.musa
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG MUSA_VERSION=rc3.1.0

FROM mthreads/musa:${MUSA_VERSION}-devel-ubuntu22.04 as build

RUN apt-get update && apt-get install -y cmake

WORKDIR /sd.cpp

COPY . .

RUN mkdir build && cd build && \
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release && \
cmake --build . --config Release

FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu22.04 as runtime

COPY --from=build /sd.cpp/build/bin/sd /sd

ENTRYPOINT [ "/sd" ]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_H
cmake --build . --config Release
```
##### Using MUSA
This provides BLAS acceleration using the MUSA cores of your Moore Threads GPU. Make sure to have the MUSA toolkit installed.
```bash
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 --build . --config Release
```

##### Using Metal

Expand Down

0 comments on commit ec3912b

Please sign in to comment.