Skip to content

Addressed a double free bug when running on CPU introduced in the last commit as well as an issue loading SDXL LoRAs #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 20, 2024

Conversation

grauho
Copy link
Contributor

@grauho grauho commented Mar 14, 2024

Fixed a double free issue when running multiple backends on the CPU, eg: CLIP and the primary backend, as this would result in the *_backend pointers both pointing to the same thing resulting in a segfault when calling the StableDiffusionGGML destructor.

grauho added 3 commits March 14, 2024 13:02
…eg: CLIP

and the primary backend, as this would result in the *_backend pointers both
pointing to the same thing resulting in a segfault when calling the
StableDiffusionGGML destructor.
…face.

Changed the base log_printf function to not bake the log level directly into
the log buffer as that information is already passed the logging function via
the level parameter and it's easier to add in there than strip it out.
…cted

naming convention, converts over the tensor name during the LoRA model
loading. Added some logging of useful LoRA loading information. Had to
increase the base size of the GGML graph as the existing size results in an
insufficient graph memory error when using SDXL LoRAs.
@grauho grauho mentioned this pull request Mar 16, 2024
@grauho grauho changed the title Addressed a double free bug when running on CPU introduced in the last commit Addressed a double free bug when running on CPU introduced in the last commit as well as an issue loading SDXL LoRAs Mar 16, 2024
@az13js
Copy link

az13js commented Mar 20, 2024

I have also encountered this issue. When using it on Windows 11, I encountered a "Segmentation fault". My fix:

$ git diff
diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp
index 4d622dd..1fa115e 100644
--- a/stable-diffusion.cpp
+++ b/stable-diffusion.cpp
@@ -123,9 +123,13 @@ public:

     ~StableDiffusionGGML() {
         ggml_backend_free(backend);
-        ggml_backend_free(clip_backend);
+        if (clip_backend != backend) {
+            ggml_backend_free(clip_backend);
+        }
         ggml_backend_free(control_net_backend);
-        ggml_backend_free(vae_backend);
+        if (vae_backend != backend) {
+            ggml_backend_free(vae_backend);
+        }
     }

@leejet
Copy link
Owner

leejet commented Mar 20, 2024

Great! Thank you for fixing this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants