- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a config file or a command line parameter to set the number of available processors for MKLnumpy to take advantage of?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome to the forum and thank you for the question!
MKL uses the best number of threads by default, e.g. (on Windows):
> python -c "import ctypes; mkl_rt = ctypes.CDLL('mkl_rt.dll'); print mkl_rt.mkl_get_max_threads()" 16
If you want to change it, set MKL_NUM_THREADS environment variable to specify the number of threads to run in parallel, e.g.:
> set MKL_NUM_THREADS=1 > python -c "import ctypes; mkl_rt = ctypes.CDLL('mkl_rt.dll'); print mkl_rt.mkl_get_max_threads()" 1
Please see this blog for more information regarding recommended environment variable settings for multithreading MKL. Or refer to MKL threading control API here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Anton Malakhov (Intel) wrote:
> python -c "import ctypes; mkl_rt = ctypes.CDLL('mkl_rt.dll'); print mkl_rt.mkl_get_max_threads()" 16
How does one check the number of threads in linux?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For linux, you need to change the name of the shared library: python -c "import ctypes; mkl_rt = ctypes.CDLL('libmkl_rt.so'); print(mkl_rt.mkl_get_max_threads())"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Robert, I was missing the 'lib' part of the name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For future reference, on a Mac you simply change "mkl_rt.dll"/"libmkl_rt.so" to "libmkl_rt.dylib", like so:
```python
python -c "import ctypes; mkl_rt = ctypes.CDLL('libmkl_rt.dylib'); print(mkl_rt.mkl_get_max_threads())"
```

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