Skip to content

Improve the "tried to allocate too many buffers" error message #3330

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 3 commits into from
Aug 2, 2021

Conversation

martin-frbg
Copy link
Collaborator

for #3321 (leaving the original message intact despite dubious grammar, as it has accumulated lots of search engine hits over the years)

@brada4
Copy link
Contributor

brada4 commented Aug 1, 2021

It reverts #3326

@martin-frbg
Copy link
Collaborator Author

Yes I need to rebase it when I'm back home tomorrow

@martin-frbg martin-frbg added this to the 0.3.18 milestone Aug 2, 2021
@martin-frbg martin-frbg merged commit b5858c4 into develop Aug 2, 2021
@matthew-brett
Copy link
Contributor

Sorry if I have misunderstood - but for the case where the number of CPUs is higher than the compiled number of threads, is it reasonable to use the compiled number of threads by default, rather than segfaulting?

@martin-frbg
Copy link
Collaborator Author

This is supposed to happen already, i.e. the number of threads (cores) found on startup is compared against the compile-time limit and should be capped at that value. Unfortunately there must be a logic flaw elsewhere in the code (and basically present since the days of GotoBLAS) but I have not managed to find it.

@ogrisel
Copy link
Contributor

ogrisel commented Aug 20, 2021

The problem happens when the threads are created externally to OpenBLAS but the user code:

  • user code calls openblas_set_num_threads(1) to run OpenBLAS in sequential mode,
  • user code creates a pool of threads of size num_threads == num_cpus > NUM_BUFFERS in its own program,
  • user code call OpenBLAS routines in each of its threads triggering the crash.

@martin-frbg It there a some public API for the user program to introspect at run time the value of NUM_BUFFERS set at OpenBLAS built time?

@ogrisel
Copy link
Contributor

ogrisel commented Aug 20, 2021

BTW in the pattern I describe above, setting OPENBLAS_NUM_THREADS to a small value will not fix the problem. It's up to the user program it-self to avoid creating too many threads. But it can only do so it has a robust way to introspect NUM_BUFFERS.

Introspecting the value of openblas_get_num_threads is not enough because this value can have been changed by a previous call to openblas_set_num_threads.

@martin-frbg
Copy link
Collaborator Author

openblas_get_config() will return either SINGLE_THREADED or MAX_THREADS=<number> as part of the configuration string

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.

4 participants