-
Notifications
You must be signed in to change notification settings - Fork 65
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
DivideByZeroException in bark_load_model when calling ggml_time_us() #189
Comments
Hello @LSXAxeller ! Thanks for reaching out. I was not aware of the BarkSharp error. I cannot really help with this as I'm not familiar with C#. I will try to sync with the latest ggml version as soon as possible, but this requires a bit of work on the bark.cpp repo side. |
I had exactly the same error when using the dll in a python binding. The fix to DivisionByZero is the same - by calling The stack overflow problem is not due to too many calls to ggml_time_init, but instead the calling stack of My fix to the problem is to manually increase the stack size limit before making calls to dll APIs in python + ctypes, it's something like
|
Thanks for your assistance, @vinovo The library is now operating and the @PABannier My apologies, I missed the And since this issue got addressed, I am going to close it. |
@LSXAxeller Thanks for the update and closing the issue! I agree we can move the Regarding syncing with ggml upstream, I'm in the process of doing so. I'm almost done adapting the Encodec.cpp codebase with the latest ggml version, which bark.cpp relies on. I should be done in a few days. |
Sorry for my late response, I opened PR #203 to call |
When calling
bark_load_model
from the C# BarkSharp wrapper, aSystem.DivideByZeroException
is thrown at the lineint64_t t_load_start_us = ggml_time_us();
. This seems to indicate that theggml_time_us()
function is attempting to divide by zero, likely because thetimer_freq
variable has not been properly initialized.Inserting a call to
ggml_time_init()
at the beginning ofbark_load_model
to initialize the timer leads to aStackOverflowException
during the allocation of memory withggml_allocr_new_from_buffer
. This suggests a potential issue with memory management or initialization within the GGML library.Reproduction Steps:
BarkContext
class constructor, providing the path to the model file.Example Code (Relevant C# snippets):
Relevant C++ Code (bark.cpp):
Relevant C++ Code (ggml.c):
Expected Behavior:
The
bark_load_model
function should load the model successfully without throwing any exceptions. Theggml_time_us()
function should return a valid timestamp.Actual Behavior:
A
System.DivideByZeroException
is thrown when callingggml_time_us()
. Attempting to fix this by callingggml_time_init()
at the beginning ofbark_load_model
results in aStackOverflowException
during memory allocation.Possible Causes:
timer_freq
variable inggml_time_us()
might not be initialized properly before it is used, leading to the division by zero error.StackOverflowException
when callingggml_time_init()
might indicate a circular dependency or a recursive function call that exceeds the stack limit.The text was updated successfully, but these errors were encountered: