-
Notifications
You must be signed in to change notification settings - Fork 148
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
Is it possible to *not* release the GIL? #136
Comments
From your description, it should not matter whether mahotas releases the GIL or not. As long as the processes created by multiprocessing are not multithreaded, the GIL should not matter. The easiest way to test would be to simply deactivate the |
Thanks for your reply. AFAIK it is not possible to confine a To illustrate my point, take a look at the linux command line tool taskset, which can confine an entire program (no matter how many processes are spawned) to a fixed number of CPUs. I think something like this is not possible with multiprocessing. Thanks for the hint about |
I did some more research and I found that the major players when it comes to parallelization (e.g. during compile-time in numpy), all have a switch to control the number of threads, e.g. via environment variables: export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1 There is also a python package that interfaces with those libraries and can change the behavior during runtime: https://github.com/joblib/threadpoolctl
|
I just realized that mahotas apparently honors the I assume this means that mahotas uses OpenMP (at least for me on Linux)? I believe this information should somehow be part of the documentation. I don't know how OpenMP plays into this during compile time of mahotas. I don't know whether Intels MKL could also affect the performance of mahotas. And since I don't understand what is going on at all, it would be helpful to explain this a little in the docs. Thanks for your time anyway. I will leave it up to you to close this issue. 👍 |
I am using mahotas in a pipeline that needs to be single-threaded, because
multiprocessing.Pool
The problem that I am having is that, e.g. when computing the Haralick texture features, each process created via
multiprocessing
now createscpu_count()
threads and I end up with 100% CPU on each core. I also think this is not very efficient.Is it possible to disable the release of the GIL in mahotas? It seems like I could do this by removing all
gil_release
statements and compiling mahotas myself.Is anyone else interested in this? Would it make sense to make available a
mahotas-gil
package on PyPI that does not release the GIL?Thanks for your thoughts!
The text was updated successfully, but these errors were encountered: