diff --git a/CMakeLists.txt b/CMakeLists.txt index 8466ed5d..455de266 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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" diff --git a/Dockerfile.musa b/Dockerfile.musa new file mode 100644 index 00000000..0126e685 --- /dev/null +++ b/Dockerfile.musa @@ -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" ] \ No newline at end of file diff --git a/README.md b/README.md index a17ef7e1..72b465f1 100644 --- a/README.md +++ b/README.md @@ -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