Intel® oneAPI Math Kernel Library (MKL) Static
mkl-static provides the static libraries for Intel® oneAPI Math Kernel Library (MKL). MKL is a highly optimized library of mathematical functions (BLAS, LAPACK, FFTs, etc.) essential for high-performance computing. It is primarily used as a backend for scientific Python libraries like NumPy and SciPy to deliver maximum performance, rather than being directly imported in Python. The current version is 2025.3.1, and it's maintained by Intel as part of their oneAPI ecosystem.
Common errors
-
MKL FATAL ERROR: Cannot load libmkl_intel_thread.so or libmkl_intel_lp64.so.
cause The Python environment or the calling library (e.g., NumPy) expects MKL, but the MKL libraries are not found in the system's library paths or are incompatible.fixEnsure `mkl-static` is installed. Check that relevant environment variables like `LD_LIBRARY_PATH` (Linux) or `DYLD_LIBRARY_PATH` (macOS) include the MKL library path, or use `conda install mkl-static` within a conda environment, which typically handles library paths automatically. Alternatively, explicitly link the dependent library against MKL. -
NumPy/SciPy performance is lower than expected, even with MKL installed.
cause The Python package (e.g., NumPy) is not actually linked against MKL, even if `mkl-static` is present in the environment. It might be linked to a generic or different BLAS/LAPACK implementation.fixRun `import numpy as np; np.__config__.show()`. Look for `mkl_info` to confirm MKL linkage. If absent, you might need to reinstall NumPy/SciPy from a source that explicitly builds against MKL (e.g., `conda install numpy scipy mkl` or using specific wheels that bundle MKL). -
ImportError: DLL load failed while importing _mkl_service: The specified module could not be found.
cause This error typically refers to the `mkl-service` package, not `mkl-static`. `mkl-service` provides Python bindings to control MKL. This error occurs when the MKL dynamic libraries are not found by `mkl-service`.fixEnsure that `mkl-static` (or another MKL provider) is correctly installed and its libraries are discoverable in your system's PATH (Windows) or LD_LIBRARY_PATH (Linux). If using Conda, `conda install mkl-service` usually resolves this by pulling in necessary MKL dependencies.
Warnings
- gotcha The `mkl-static` package does NOT provide any direct Python imports or modules. It solely provides the underlying MKL binary libraries for other Python packages (like NumPy, SciPy, scikit-learn) to link against during their installation or at runtime.
- breaking Incorrect MKL setup can lead to performance degradation or runtime errors if a library expects MKL but finds a different BLAS/LAPACK implementation, or none at all.
- gotcha Mixing `mkl-static` with other BLAS/LAPACK providers (like OpenBLAS or netlib LAPACK) or MKL versions in the same environment can lead to subtle bugs or crashes.
Install
-
pip install mkl-static
Quickstart
import numpy as np
print('NumPy version:', np.__version__)
print('NumPy configuration:\n', np.__config__.show())
# Expected output for MKL linkage will show 'mkl_info' or similar entries.