Skip to content

Exception at ggml_free when lora is used in the prompt and free_sd_ctx called #175

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

Closed
fszontagh opened this issue Feb 12, 2024 · 1 comment

Comments

@fszontagh
Copy link
Contributor

"Exception thrown at 0x00007FFABCBCC55C (ucrtbased.dll) in sd.ui.exe: 0xC0000005: Access violation reading location 0x000001E123A9C07C."

Which is occured at

void ggml_free(struct ggml_context * ctx)

at line 2355 in ggml.c
image

Which is called from ggml_extend.hpp at ggml_free

void free_params_buffer() {
        if (params_ctx != NULL) {
            ggml_free(params_ctx);
            params_ctx = NULL;
        }
...

which is called from the destructor of the GGMLModule

    ~GGMLModule() {
        free_params_buffer();
    }

Which is called from the LoraModel destructor (extended from GGMLModule)

Which is called from StableDiffusionGGML destructor:

    ~StableDiffusionGGML() {
        ggml_backend_free(backend);
    }

which is called from free_sd_ctx what i called to remove the model from the (v)ram

I tried the following situations:

  • sd_ctx is loaded, no lora defined in the prompt: free_sd_ctx is working as expected to multiple times after text2img
  • sd_ctx is loaded, added lora to the prompt, multiple text2img is okay
  • sd_ctx is loaded, added lora to the prompt, then lora removed from prompt, text2img produce the same effect with defined lora in prompt
  • sd_ctx is loaded, lora added to the prompt, txt2img done multiple times, bat can not free_sd_ctx

I think it's the same effect with the embeddings

fszontagh added a commit to fszontagh/stable-diffusion.cpp that referenced this issue Feb 15, 2024
@fszontagh
Copy link
Contributor Author

The new master branch resolves this.

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

No branches or pull requests

1 participant