-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
ImportError: PyCapsule_Import could not import module "datetime" #14474
Comments
NumPy 1.17.1, correct? What python version/platform. The problematic call looks to be from the cpython macro |
Yes correct numpy version. Python version 3.6.8. Yes this used to work before.
I hope it helps. |
What happens if you import matplotlib once in the process before starting your threads? |
Or maybe |
As far as I can tell, this happens in This might be due to a faulty python installation where |
Without changing anything. I have run the actual script again and it did not fail immediatly. Instead I received only this error again:
At the moment I cannot recreate the state where it would fail immediately with the exeception in the first comment. I assume the problem is something dynamic controlled by the os?
All these imports are currently working fine. |
You may be saturating your machine by running many processes. Importing numpy in each process will open a thread pool with the number of threads equal to number of CPUs, so if you have 64 cpus and open 100 processes that will be thousands of threads. You might be interested in |
Hmm okay that makes sense. In my case this would be 88 process * 88 cpus = 7744 threads. I tried limiting the number of threads per cpu to one, but unfortunately this did not work. I received the same errors again and in the end I ended up in the state where numpy would immediately crash after import. I am connected via ssh to a server where I run this code. What I noticed is that when closing the ssh connection and then connecting again, numpy does not crash immediately after import. |
Did you use threadpoolctl? Perhaps you could continue this part of the issue with them |
I had the same problem using Jobe - a sandbox for running code. What worked was inserting these lines in the script before importing numpy.
So yeah, looks like limiting the number of thread works. |
Still has this problem in 2022 with Python 3.9.0 and numpy 1.22.3 . Adding |
This issue is closed. Please open a new one with the error message. Is there anything out of the ordinary about this machine: does it have a large number of CPUs or is it lacking memory? |
Yes, it is on an HPC with hundreds of nodes and 128 cores on each node. Do you mean |
Hundred of nodes and 128 cores on each node is not a configuration we can test on, so stock NumPy (or OpenBLAS) will need some guidance on resource allocation. This may have improved in the 1.23 releases, but ultimately some strategy to allocate resources will be needed. |
Does OPENBLAS_NUM_THREADS=1 have a heavy influence in performance? btw still having this issue in a single node with 40 cores, python 3.11.4 + numpy 1.25.1, should I open an issue? |
Nevermind it was an issue with Docker (seccomp not allowing pthread_create). |
It was caused by |
I found the workaround in a bit of an unrelated conversation (HumanSignal/label-studio#3070), the things is that apparently this does not affect current versions of Docker so I couldn't find out more information about this at the time. |
I use |
attempt at fixing OpenBLAS-related nproc limit see: numpy/numpy#14474
Reproducing code example:
Before this happened I was running a different python script, which used 89 processes. Unfortunately I cannot share that script publicly. Since then numpy crashes after import immediately.
Error message:
Numpy/Python version information:
numpy-1.7.1-13.el7.x86_64
The text was updated successfully, but these errors were encountered: