Skip to content

Commit d7af0a6

Browse files
committed
Support Moore Threads GPU
Signed-off-by: Xiaodong Ye <[email protected]>
1 parent 9578fdc commit d7af0a6

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ option(SD_HIPBLAS "sd: rocm backend" OFF)
2929
option(SD_METAL "sd: metal backend" OFF)
3030
option(SD_VULKAN "sd: vulkan backend" OFF)
3131
option(SD_SYCL "sd: sycl backend" OFF)
32+
option(SD_MUSA "sd: musa backend" OFF)
3233
option(SD_FAST_SOFTMAX "sd: x1.5 faster softmax, indeterministic (sometimes, same seed don't generate same image), cuda only" OFF)
3334
option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF)
3435
#option(SD_BUILD_SERVER "sd: build server example" ON)
@@ -60,9 +61,18 @@ if (SD_HIPBLAS)
6061
endif()
6162
endif ()
6263

64+
if(SD_MUSA)
65+
message("-- Use MUSA as backend stable-diffusion")
66+
set(GGML_MUSA ON)
67+
add_definitions(-DSD_USE_CUBLAS)
68+
if(SD_FAST_SOFTMAX)
69+
set(GGML_CUDA_FAST_SOFTMAX ON)
70+
endif()
71+
endif()
72+
6373
set(SD_LIB stable-diffusion)
6474

65-
file(GLOB SD_LIB_SOURCES
75+
file(GLOB SD_LIB_SOURCES
6676
"*.h"
6777
"*.cpp"
6878
"*.hpp"

Dockerfile.musa

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG MUSA_VERSION=rc3.1.0
2+
3+
FROM mthreads/musa:${MUSA_VERSION}-devel-ubuntu22.04 as build
4+
5+
RUN apt-get update && apt-get install -y cmake
6+
7+
WORKDIR /sd.cpp
8+
9+
COPY . .
10+
11+
RUN mkdir build && cd build && \
12+
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build . --config Release
14+
15+
FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu22.04 as runtime
16+
17+
COPY --from=build /sd.cpp/build/bin/sd /sd
18+
19+
ENTRYPOINT [ "/sd" ]

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_H
132132
cmake --build . --config Release
133133
```
134134
135+
##### Using MUSA
136+
137+
This provides BLAS acceleration using the MUSA cores of your Moore Threads GPU. Make sure to have the MUSA toolkit installed.
138+
139+
```bash
140+
cmake .. -DCMAKE_C_COMPILER=/usr/local/musa/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/musa/bin/clang++ -DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release
141+
cmake --build . --config Release
142+
```
135143

136144
##### Using Metal
137145

0 commit comments

Comments
 (0)