Skip to content

Commit 057abde

Browse files
committed
merge with master fd693ac
* used the sample_params member to keep the parameters in SDParams * fixed 'threshold' typo in stable-diffusion.cpp
2 parents 60305ce + fd693ac commit 057abde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+770292
-2579
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jobs:
163163
- build: "avx512"
164164
defines: "-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
165165
- build: "cuda12"
166-
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES=90;89;80;75"
166+
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES=90;89;86;80;75"
167167
# - build: "rocm5.5"
168168
# defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON'
169169
- build: 'vulkan'
@@ -254,15 +254,15 @@ jobs:
254254
255255
- name: Copy and pack Cuda runtime
256256
id: pack_cuda_runtime
257-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.build == 'cuda12' ) || github.event.inputs.create_release == 'true' }}
257+
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true') }}
258258
run: |
259259
echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
260260
$dst='.\build\bin\cudart\'
261261
robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
262262
7z a cudart-sd-bin-win-cu12-x64.zip $dst\*
263263
264264
- name: Upload Cuda runtime
265-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.build == 'cuda12' ) || github.event.inputs.create_release == 'true' }}
265+
if: ${{ matrix.build == 'cuda12' && (github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true') }}
266266
uses: actions/upload-artifact@v4
267267
with:
268268
name: sd-cudart-sd-bin-win-cu12-x64.zip
@@ -288,6 +288,11 @@ jobs:
288288
- windows-latest-cmake
289289

290290
steps:
291+
- name: Clone
292+
uses: actions/checkout@v3
293+
with:
294+
fetch-depth: 0
295+
291296
- name: Download artifacts
292297
id: download-artifact
293298
uses: actions/download-artifact@v4
@@ -296,20 +301,27 @@ jobs:
296301
pattern: sd-*
297302
merge-multiple: true
298303

304+
- name: Get commit count
305+
id: commit_count
306+
run: |
307+
echo "count=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT
308+
299309
- name: Get commit hash
300310
id: commit
301311
uses: pr-mpt/actions-commit-hash@v2
302312

303313
- name: Create release
304314
id: create_release
315+
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
305316
uses: anzz1/action-create-release@v1
306317
env:
307318
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
308319
with:
309-
tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
320+
tag_name: ${{ format('{0}-{1}-{2}', env.BRANCH_NAME, steps.commit_count.outputs.count, steps.commit.outputs.short) }}
310321

311322
- name: Upload release
312323
id: upload_release
324+
if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == 'master' }}
313325
uses: actions/github-script@v3
314326
with:
315327
github-token: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
build*/
2+
cmake-build-*/
23
test/
34
.vscode/
5+
.idea/
46
.cache/
57
*.swp
6-
.vscode/
78
*.bat
89
*.bin
910
*.exe
1011
*.gguf
1112
output*.png
1213
models*
13-
*.log
14+
*.log

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "ggml"]
22
path = ggml
3-
url = https://github.com/ggerganov/ggml.git
3+
url = https://github.com/ggml-org/ggml.git

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ option(SD_SYCL "sd: sycl backend" OFF)
3333
option(SD_MUSA "sd: musa backend" OFF)
3434
option(SD_FAST_SOFTMAX "sd: x1.5 faster softmax, indeterministic (sometimes, same seed don't generate same image), cuda only" OFF)
3535
option(SD_BUILD_SHARED_LIBS "sd: build shared libs" OFF)
36+
option(SD_USE_SYSTEM_GGML "sd: use system-installed GGML library" OFF)
3637
#option(SD_BUILD_SERVER "sd: build server example" ON)
3738

3839
if(SD_CUDA)
@@ -118,23 +119,37 @@ endif()
118119

119120
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
120121

121-
# see https://github.com/ggerganov/ggml/pull/682
122-
add_definitions(-DGGML_MAX_NAME=128)
122+
if (NOT SD_USE_SYSTEM_GGML)
123+
# see https://github.com/ggerganov/ggml/pull/682
124+
add_definitions(-DGGML_MAX_NAME=128)
125+
endif()
123126

124127
# deps
125128
# Only add ggml if it hasn't been added yet
126129
if (NOT TARGET ggml)
127-
add_subdirectory(ggml)
130+
if (SD_USE_SYSTEM_GGML)
131+
find_package(ggml REQUIRED)
132+
if (NOT ggml_FOUND)
133+
message(FATAL_ERROR "System-installed GGML library not found.")
134+
endif()
135+
add_library(ggml ALIAS ggml::ggml)
136+
else()
137+
add_subdirectory(ggml)
138+
endif()
128139
endif()
129140

130141
add_subdirectory(thirdparty)
131142

132143
target_link_libraries(${SD_LIB} PUBLIC ggml zip)
133144
target_include_directories(${SD_LIB} PUBLIC . thirdparty)
134-
target_compile_features(${SD_LIB} PUBLIC cxx_std_11)
145+
target_compile_features(${SD_LIB} PUBLIC c_std_11 cxx_std_17)
135146

136147

137148
if (SD_BUILD_EXAMPLES)
138149
add_subdirectory(examples)
139150
endif()
140151

152+
set(SD_PUBLIC_HEADERS stable-diffusion.h)
153+
set_target_properties(${SD_LIB} PROPERTIES PUBLIC_HEADER "${SD_PUBLIC_HEADERS}")
154+
155+
install(TARGETS ${SD_LIB} LIBRARY PUBLIC_HEADER)

Dockerfile.musa

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
ARG MUSA_VERSION=rc3.1.1
1+
ARG MUSA_VERSION=rc4.2.0
2+
ARG UBUNTU_VERSION=22.04
23

3-
FROM mthreads/musa:${MUSA_VERSION}-devel-ubuntu22.04 as build
4+
FROM mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}-amd64 as build
45

56
RUN apt-get update && apt-get install -y ccache cmake git
67

@@ -15,7 +16,7 @@ RUN mkdir build && cd build && \
1516
-DSD_MUSA=ON -DCMAKE_BUILD_TYPE=Release && \
1617
cmake --build . --config Release
1718

18-
FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu22.04 as runtime
19+
FROM mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}-amd64 as runtime
1920

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

Dockerfile.sycl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG SYCL_VERSION=2025.1.0-0
2+
3+
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.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=icx -DCMAKE_CXX_COMPILER=icpx -DSD_SYCL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build . --config Release -j$(nproc)
14+
15+
FROM intel/oneapi-basekit:${SYCL_VERSION}-devel-ubuntu24.04 AS runtime
16+
17+
COPY --from=build /sd.cpp/build/bin/sd /sd
18+
19+
ENTRYPOINT [ "/sd" ]

0 commit comments

Comments
 (0)