Skip to content
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

Not having enough memory just causes a segfault or something #257

Closed
LoganDark opened this issue Mar 18, 2023 · 9 comments
Closed

Not having enough memory just causes a segfault or something #257

LoganDark opened this issue Mar 18, 2023 · 9 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists hardware Hardware related model Model specific

Comments

@LoganDark
Copy link
Contributor

So. I'm trying to build with CMake on Windows 11 and the thing just stops after it's done loading the model.

image

And apparently, this is a segfault.

Screenshot_20230318_121935

Yay yay yyayy yyayay

this is a memory allocation failure it seems, from me not having enough memory. not like llama.cpp Tells Me That lmao, it just segfaults

(ctx->mem_buffer is nullptr which probably means the malloc just failed)

@LoganDark
Copy link
Contributor Author

can confirm clearing tons of memory seems to make it work:

image

@LoganDark
Copy link
Contributor Author

LoganDark commented Mar 18, 2023

Performing the quantization step from f16 down to q4_0 significantly helps with the memory usage (I am dumb but eventually figured this out even though I was supposed to do it anyway)

It does make the model extra drunk though (which I guess is to be expected from the 7B version)

@gadzbi123
Copy link

I was wondering why the q4_0 was giving such a wierd responses

@LoganDark
Copy link
Contributor Author

I was wondering why the q4_0 was giving such a wierd responses

q4_0 will say 2 + 2 = 10, then proceeds to explain how that's because they are in their "respective ranges" of "-5 through 8" by not being "greater than 9 or lesser than -4", but that's also an off-by-one error, not like it matters because what?

image

It's actually hilarious

@gjmulder gjmulder added duplicate This issue or pull request already exists hardware Hardware related model Model specific bug Something isn't working labels Mar 19, 2023
@tjohnman
Copy link
Contributor

tjohnman commented Mar 19, 2023

Detecting when a stack overflow is going to happen in a portable way is tricky. If we could use malloc() to allocate this memory it would be able to fail gracefully.

@LoganDark
Copy link
Contributor Author

LoganDark commented Mar 19, 2023

Detecting when a stack overflow is going to happen in a portable way is tricky.

Is this a stack overflow? ctx->mem_buffer is null. Clearly an actual allocation failed first and the segfault happened because of an attempt to access something through the resulting null pointer. Which could have been detected earlier and handled cleanly without segfaulting (i.e. printing an error message and exiting)

@tjohnman
Copy link
Contributor

You're right, my bad. In that case it should be easier to deal with.

@sw
Copy link
Contributor

sw commented May 6, 2023

There is now an assert that checks mem_buffer, even in non-debug builds:
https://github.com/ggerganov/llama.cpp/blob/173d0e6419e8f8f3c1f4f13201b777f4c60629f3/ggml.c#L4571

Closing this as it's quite old, please re-open if you still encounter the problem with a recent revision.

@sw sw closed this as completed May 6, 2023
@LoganDark
Copy link
Contributor Author

There is now an assert that checks mem_buffer, even in non-debug builds:

Yep, that looks like it would fix it~

Closing this as it's quite old

Actually you'd be closing it because it's solved lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists hardware Hardware related model Model specific
Projects
None yet
Development

No branches or pull requests

5 participants