I'm using OpenBLAS via numpy with Python 2.7. I run code in a limited environment (a sandbox for running student and instructor code on edX), so I try to limit the resources used. On Ubuntu 12.04, I set RLIMIT_NPROC to 0, to prevent subprocesses. But on Ubuntu 16.04, that limit also applies to threads. When I run some sample code, it fails with this output:
OpenBLAS blas_thread_init: pthread_create: Resource temporarily unavailable
OpenBLAS blas_thread_init: RLIMIT_NPROC 0 current, 0 max
Traceback (most recent call last):
File "jailed_code", line 15, in <module>
exec code in g_dict
File "<string>", line 3, in <module>
File "/edx/app/edxapp/venvs/edxapp-sandbox/local/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/edx/app/edxapp/venvs/edxapp-sandbox/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/edx/app/edxapp/venvs/edxapp-sandbox/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/edx/app/edxapp/venvs/edxapp-sandbox/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/edx/app/edxapp/venvs/edxapp-sandbox/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 11, in <module>
from numeric import *
File "/edx/app/edxapp/venvs/edxapp-sandbox/local/lib/python2.7/site-packages/numpy/core/numeric.py", line 817, in <module>
from _dotblas import dot, vdot, inner, alterdot, restoredot
KeyboardInterrupt
Is there some way that I can instruct OpenBLAS not to use any threads at all? I've searched postings in this group, but I am confused about which options are build-time, and which are run-time. I've tried a few of the environment variables (OPENBLAS_NUM_THREADS and OMP_NUM_THREADS), but they don't have any effect. It isn't an option for me to build my own OpenBLAS. Is there anything I can do?
Thanks,
--Ned.