Limit number of threads when running on CPU
See original GitHub issueI am assembling a single-core CPU performance benchmark for various HPC libraries from the modern Python ecosystem. I would like to include JAX, and first results seem very promising, but I’m failing to restrict it to a single thread. As far as I can tell, there is no corresponding setting in jax.config
, and it doesn’t listen to any of the popular flags (e.g. OMP_NUM_THREADS
).
I installed JAX and jaxlib from PyPI on OSX.
Is there any way to pull this off?
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (12 by maintainers)
Top Results From Across the Web
Maximum number of threads CPU - Stack Overflow
It really depends. As a rule of thumb, limit the number of threads to something close to the number of cores (otherwise you...
Read more >How can I tell the maximum threads my server can run?
So, you can have a total maximum of 20 threads executing in parallel, one thread per CPU/core. That can mean 20 single-threaded jobs, ......
Read more >What is the theoretical and practical limit on the numbers of ...
If you have a quad-core processor, you can have four hardware threads, or eight hardware threads if your processor is hyper-threaded. What this...
Read more >Maximum Number of Threads Per Process in Linux - Baeldung
The threads-max kernel parameter can be set to ensure that the number of threads per process is always less than or equal to...
Read more >Specify Maximum Number of Threads to Run Parallel for ...
Specify Maximum Number of Threads to Run Parallel for -Loops in the Generated Code ; 2. Configuration property (default value = 0):. NumberOfCpuThreads....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A quick note: setting the task affinity map is the correct way to limit JAX’s CPU usage at the moment. JAX sizes its main threadpool using this logic: https://github.com/tensorflow/tensorflow/blob/4b2cb67756009dda843c6b56a8b320c8a54373e0/tensorflow/core/platform/default/port.cc#L67
If launching from
mpirun
,mpirun
knows how to set task affinities correctly.Hey @dionhaefner ! I had a similar issue: https://github.com/google/jax/issues/743 HTH