From 10bfa545ff4011b9e7a5696ee55ca9012159852b Mon Sep 17 00:00:00 2001 From: Markus Hartung Date: Sun, 7 Sep 2025 04:15:12 +0200 Subject: [PATCH 1/3] * Updated README.md to avoid deprecated AMDGPU_TARGETS * Updated lora.md to clarify that not all quants are supported * Fixed so --clip-on-cpu hint is not shown when using it * Creates parent directory if not exists * Added .idea folder used for CLion --- .idea/.gitignore | 8 + .idea/.name | 1 + .idea/codeStyles/Project.xml | 105 ++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/editor.xml | 344 +++++++++++++++++++++++++++ .idea/encodings.xml | 4 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/stable-diffusion.cpp.iml | 2 + .idea/vcs.xml | 7 + README.md | 4 +- docs/lora.md | 28 ++- examples/cli/main.cpp | 14 ++ stable-diffusion.cpp | 2 +- 14 files changed, 536 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/editor.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/stable-diffusion.cpp.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 000000000..684185152 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +stable-diffusion \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 000000000..81469bdc3 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,105 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 000000000..79ee123c2 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 000000000..0093ef66d --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,344 @@ + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..df87cf951 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..0b76fe510 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..c930abe40 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/stable-diffusion.cpp.iml b/.idea/stable-diffusion.cpp.iml new file mode 100644 index 000000000..f08604bb6 --- /dev/null +++ b/.idea/stable-diffusion.cpp.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..546bd1097 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index a5b181aad..e92e029de 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,9 @@ This provides BLAS acceleration using the ROCm cores of your AMD GPU. Make sure Windows User Refer to [docs/hipBLAS_on_Windows.md](docs%2FhipBLAS_on_Windows.md) for a comprehensive guide. ``` -cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS=gfx1100 -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON +export GFX_NAME=$(rocminfo | grep -m 1 -E "gfx[^0]{1}" | sed -e 's/ *Name: *//' | awk '{$1=$1; print}' || echo "rocminfo missing") +echo $GFX_NAME +cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DGPU_TARGETS=$GFX_NAME -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON cmake --build . --config Release ``` diff --git a/docs/lora.md b/docs/lora.md index fb76f287c..e2e1d82e9 100644 --- a/docs/lora.md +++ b/docs/lora.md @@ -10,4 +10,30 @@ Here's a simple example: ./bin/sd -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat" --lora-model-dir ../models ``` -`../models/marblesh.safetensors` or `../models/marblesh.ckpt` will be applied to the model \ No newline at end of file +`../models/marblesh.safetensors` or `../models/marblesh.ckpt` will be applied to the model + +# Support matrix + +> ℹ️ CUDA `get_rows` support is defined here: +> [ggml-org/ggml/src/ggml-cuda/getrows.cu#L156](https://github.com/ggml-org/ggml/blob/7dee1d6a1e7611f238d09be96738388da97c88ed/src/ggml-cuda/getrows.cu#L156) +> Currently only the basic types + Q4/Q5/Q8 are implemented. K-quants are **not** supported. + +NOTE: The other backends may have different support. + +| Quant / Type | CUDA | +|--------------|------| +| F32 | ✔️ | +| F16 | ✔️ | +| BF16 | ✔️ | +| I32 | ✔️ | +| Q4_0 | ✔️ | +| Q4_1 | ✔️ | +| Q5_0 | ✔️ | +| Q5_1 | ✔️ | +| Q8_0 | ✔️ | +| Q2_K | ❌ | +| Q3_K | ❌ | +| Q4_K | ❌ | +| Q5_K | ❌ | +| Q6_K | ❌ | +| Q8_K | ❌ | diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index 94cdbdb91..62f972378 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -25,6 +25,7 @@ #include "stb_image_resize.h" #include "avi_writer.h" +#include #if defined(_WIN32) #define NOMINMAX @@ -1314,6 +1315,19 @@ int main(int argc, const char* argv[]) { continue; } std::string final_image_path = i > 0 ? base_path + "_" + std::to_string(i + 1) + file_ext : base_path + file_ext; + + namespace fs = std::filesystem; + const fs::path out_path = params.output_path; + if (const fs::path out_dir = out_path.parent_path(); !out_dir.empty()) { + std::error_code ec; + fs::create_directories(out_dir, ec); // OK if already exists + if (ec) { + fprintf(stderr, "failed to create directory '%s': %s\n", + out_dir.string().c_str(), ec.message().c_str()); + return 1; + } + } + if (is_jpg) { stbi_write_jpg(final_image_path.c_str(), results[i].width, results[i].height, results[i].channel, results[i].data, 90, get_image_params(params, params.seed + i).c_str()); diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index 64164a2fb..70964ee45 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -330,7 +330,7 @@ class StableDiffusionGGML { if (sd_version_is_dit(version)) { use_t5xxl = true; } - if (!ggml_backend_is_cpu(backend) && use_t5xxl) { + if (!clip_on_cpu && !ggml_backend_is_cpu(backend) && use_t5xxl) { LOG_WARN( "!!!It appears that you are using the T5 model. Some backends may encounter issues with it." "If you notice that the generated images are completely black," From 163cf493ce38e9862f09e3c9d28c22c0c7665cd6 Mon Sep 17 00:00:00 2001 From: Markus Hartung Date: Mon, 8 Sep 2025 00:05:05 +0200 Subject: [PATCH 2/3] Ingore CLion .idea folder --- .gitignore | 3 +- .idea/.gitignore | 8 - .idea/.name | 1 - .idea/codeStyles/Project.xml | 105 -------- .idea/codeStyles/codeStyleConfig.xml | 5 - .idea/editor.xml | 344 --------------------------- .idea/encodings.xml | 4 - .idea/misc.xml | 7 - .idea/modules.xml | 8 - .idea/stable-diffusion.cpp.iml | 2 - .idea/vcs.xml | 7 - 11 files changed, 2 insertions(+), 492 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/.name delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/editor.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/stable-diffusion.cpp.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 38fe570df..7d32dea06 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,11 @@ test/ .cache/ *.swp .vscode/ +.idea/ *.bat *.bin *.exe *.gguf output*.png models* -*.log \ No newline at end of file +*.log diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 684185152..000000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -stable-diffusion \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 81469bdc3..000000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123c2..000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml deleted file mode 100644 index 0093ef66d..000000000 --- a/.idea/editor.xml +++ /dev/null @@ -1,344 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index df87cf951..000000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 0b76fe510..000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c930abe40..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/stable-diffusion.cpp.iml b/.idea/stable-diffusion.cpp.iml deleted file mode 100644 index f08604bb6..000000000 --- a/.idea/stable-diffusion.cpp.iml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 546bd1097..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file From a87aa16fefa7fbd521cee93ea1ca73d9e41d71c7 Mon Sep 17 00:00:00 2001 From: leejet Date: Mon, 8 Sep 2025 22:37:38 +0800 Subject: [PATCH 3/3] format code --- examples/cli/main.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index 657c3a4d2..098c98cc5 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include "stb_image_resize.h" #include "avi_writer.h" -#include #if defined(_WIN32) #define NOMINMAX @@ -1284,6 +1284,21 @@ int main(int argc, const char* argv[]) { } } + // create directory if not exists + { + namespace fs = std::filesystem; + const fs::path out_path = params.output_path; + if (const fs::path out_dir = out_path.parent_path(); !out_dir.empty()) { + std::error_code ec; + fs::create_directories(out_dir, ec); // OK if already exists + if (ec) { + fprintf(stderr, "failed to create directory '%s': %s\n", + out_dir.string().c_str(), ec.message().c_str()); + return 1; + } + } + } + std::string base_path; std::string file_ext; std::string file_ext_lower; @@ -1320,19 +1335,6 @@ int main(int argc, const char* argv[]) { continue; } std::string final_image_path = i > 0 ? base_path + "_" + std::to_string(i + 1) + file_ext : base_path + file_ext; - - namespace fs = std::filesystem; - const fs::path out_path = params.output_path; - if (const fs::path out_dir = out_path.parent_path(); !out_dir.empty()) { - std::error_code ec; - fs::create_directories(out_dir, ec); // OK if already exists - if (ec) { - fprintf(stderr, "failed to create directory '%s': %s\n", - out_dir.string().c_str(), ec.message().c_str()); - return 1; - } - } - if (is_jpg) { stbi_write_jpg(final_image_path.c_str(), results[i].width, results[i].height, results[i].channel, results[i].data, 90, get_image_params(params, params.seed + i).c_str());