- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just installed Intel-MKL numpy in a mostly new machine. Everything works well, with one exception: it keeps using only 4 CPU threads when my computer has 8.
Before anyone asks, I use Ubuntu 18.4 and when I run the following in the terminal:
cat /proc/cpuinfo | grep processor | wc -le
I do get "8" as the output - so yeah, I do have 8 threads. Yet, I can see that only 4 threads are being used both if I check my System Monitor, if I use "top" in the terminal or if I run something like:
In [1]: import os In [2]: os.environ['MKL_VERBOSE']="1" In [3]: import numpy as np Numpy + Intel(R) MKL: THREADING LAYER: (null) Numpy + Intel(R) MKL: setting Intel(R) MKL to use INTEL OpenMP runtime Numpy + Intel(R) MKL: preloading libiomp5.so runtime MKL_VERBOSE Intel(R) MKL 2019.0 Product build 20180829 for Intel(R) 64 architecture Intel(R) Advanced Vec tor Extensions 2 (Intel(R) AVX2) enabled processors, Lnx 2.60GHz lp64 intel_thread MKL_VERBOSE SDOT(2,0x5622fcf3f9c0,1,0x5622fcf3f9c0,1) 2.06ms CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:4 In [4]: x = np.random.randn(1000) In [5]: np.dot(x,x) MKL_VERBOSE DDOT(1000,0x5622fd5b8280,1,0x5622fd5b8280,1) 31.63us CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:4 Out[5]: 941.6605280631609
Let me reinforce this, to be very clear: it's not that Intel-MKL is detecting cores and I am talking about threads. No. The example above (and any other) show that only 4 of my threads get used during the numpy matrix operations - with the other 4 threads sitting close to idle.
I have tried what is told in this forum post, i.e. going Ubuntu's terminal and doing:
set MKL_NUM_THREADS=7
I also tried:
import mkl mkl.set_num_threads(7)
But it seems that Intel-MKL is wrongly detecting my max number of threads to be 4:
In [36]: mkl.get_max_threads() Out[36]: 4
It should not be this hard to make multithreaded libraries make use of all threads I have available. Anyhow, your time helping me fix this is much appreciated.
Link Copied

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page