-
Notifications
You must be signed in to change notification settings - Fork 3
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
Invalid NUMBA_NUM_THREADS while running with Numpy #107
Comments
def gen_snt_check():
from numba.core.config import NUMBA_NUM_THREADS
msg = "The number of threads must be between 1 and %s" % NUMBA_NUM_THREADS
def snt_check(n):
if n > NUMBA_NUM_THREADS or n < 1:
raise ValueError(msg)
return snt_check
snt_check = gen_snt_check() So someone is setting |
And also, when inside IPython in the same environment, I get: [ins] In [1]: import numba
[ins] In [2]: numba.config
Out[2]: <module 'numba.core.config' from '/media/alessandro/moneybin/Projects/Qibo/qibotn/env/lib/python3.10/site-packages/numba/core/config.py'>
[ins] In [3]: numba.config.NUMBA_NUM_THREADS
Out[3]: 12 while clearly Numba is resolving it to 6 during |
Did you check quimb import call? |
The import quimb as qu
import quimb.tensor as qtn I'm going to check immediately inside |
You were right, culprit found: import psutil
_NUM_THREAD_WORKERS = psutil.cpu_count(logical=False)
if "NUMBA_NUM_THREADS" in os.environ:
if int(os.environ["NUMBA_NUM_THREADS"]) != _NUM_THREAD_WORKERS:
import warnings
warnings.warn(
"'NUMBA_NUM_THREADS' has been set elsewhere and doesn't match the "
"value 'quimb' has tried to set - "
f"{os.environ['NUMBA_NUM_THREADS']} vs {_NUM_THREAD_WORKERS}."
)
else:
os.environ["NUMBA_NUM_THREADS"] = str(_NUM_THREAD_WORKERS) |
Indeed, this is working:
The explanation is a few lines above those cited in the previous comment. |
@scarrazza then I guess I shoul move this issue to If you agree, I will "transfer" the issue there (i.e. open a new one, since being a private repo I can't actually transfer). |
Sure, please go ahead. |
This is at least outdated. The issue content will still be available, if needed, so there is no need to keep it opened. |
This is causing an issue with tests in |
While debugging a very simple tests for
qibotn
(on theqibotn:pypkg
branch) I encountered the error reported below, coming from Numba backend, even though the Numpy one was selected.As @stavros11 already noticed correctly, the
cupy
behavior is perfectly expected and adequate, so the actual issues are:Most likely the problem is machine dependent, since my machine has 6 cores (x2 with hyperthreading), so the total number (i.e. 12) exceeds the maximum of 6 requested by Numba.
However, I don't get why Numba is imposing a maximum at all, nor why it is happening with
qibojit
, but never happened with other Numba projects (for which the answer might be actually more complicated, and I don't expect to be found here...)Pytest run with traceback
CPU details
The text was updated successfully, but these errors were encountered: