OpenBLAS: OpenBLAS : Program will terminate because you tried to start too many threads.
I recently built OpenBLAS 0.3.2 on Ubuntu 16 and am running into this error.
OpenBLAS : Program will terminate because you tried to start too many threads.
My program is using a library that allocates many threads for various reasons. Most of the threads are sleeping most of the time, so there are no performance issues, but I guess that the large number of threads is too much…
Does linking to OpenBLAS really limit the max number of threads that the program creates, even if those threads are not making blas calls? Is there a way around this?
FWIW, I have done a lot of searching and reading on the topic, but still can’t quite figure out how to solve this… Some notes:
- I was not getting this error with a previous version of OpenBLAS (whatever is in he Ubuntu repo)
 - I also tried building with 
USE_OPENMP=1but that doesn’t seem to fix the problem. - I tried with 
OPENBLAS_NUM_THREADS=1environment variable which seemed to make no difference - I tried calling 
openblas_set_num_threads(1)at runtime which seemd to make some difference, but eventually I got the same error - I tried building with 
USE_THREAD=0. I think this prevents the error but I haven’t found clear documentation as to what the implications are. Can I still call blas functions in multiple threads safely (on unrelated data of course)? Does blas do everything in a single thread in this case or in whatever thread it’s called from? 
Thanks much.
About this issue
- Original URL
 - State: closed
 - Created 6 years ago
 - Reactions: 2
 - Comments: 24 (6 by maintainers)
 
@susilehtola with stock 0.3.3 you would actually need to remove or comment out the USE_TLS=1 line in Makefile.rule as I had continued the bad tradition in OpenBLAS of making a variable look like a Boolean while only checking if it is defined at all. ☹️
From #1761 it appears I made a mistake though, as the new USE_TLS option is on by default in 0.3.3 when you build with plain make - it needs to be commented out in Makefile.rule to actually get the 0.3.0 version of memory.c
0.3.3 is released now, reverting to the old code until we get to the bottom of this.