Intel oneAPI Math Kernel Library License
Intel oneAPI Math Kernel Library (oneMKL) is a collection of optimized math routines for scientific, engineering, and financial applications, including BLAS, LAPACK, sparse solvers, FFTs, and vector math. The `onemkl-license` PyPI package provides the licensing information for Intel oneMKL. It is not a direct Python-callable library for mathematical computations but rather a component that signifies the presence and licensing of the underlying oneMKL binaries, which are typically utilized by other Python packages (e.g., NumPy, SciPy) or through specific Python bindings like `mkl-service`, `mkl-fft`, and `mkl-random`. The current version is 2025.3.1, with releases tied to the oneAPI toolkit cadence.
Common errors
-
ModuleNotFoundError: No module named 'mkl'
cause Attempting to import `mkl` (for runtime control) without installing the `mkl-service` package.fixInstall the `mkl-service` package: `pip install mkl-service` or `conda install mkl-service`. -
numpy.linalg.LinAlgError: Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.so or libmkl_intel_lp64.so.
cause The Python environment (e.g., NumPy, SciPy) expects oneMKL libraries but cannot find them, often due to incorrect `LD_LIBRARY_PATH` (Linux) or `PATH` (Windows) or an incomplete oneMKL installation.fixEnsure Intel oneMKL is correctly installed (e.g., via `conda install intel-oneapi-mkl`) and that environment variables like `LD_LIBRARY_PATH` (Linux) or `PATH` (Windows) include the paths to the MKL shared libraries. Setting `MKLROOT` might also be necessary. -
Undefined symbols for architecture x86_64: "_cblas_dgemm" (macOS link error)
cause When compiling C/C++/Fortran code that uses oneMKL functions, the linker cannot find the MKL routines. This often happens when MKL is installed but not correctly linked during the compilation process.fixEnsure the compiler and linker flags correctly point to the oneMKL include and library directories. Use the oneMKL Link Line Advisor tool (available on Intel's developer website) to generate the correct compilation and linking commands for your specific environment and desired features.
Warnings
- gotcha The `onemkl-license` package is primarily a placeholder for licensing and dependency resolution, not a library to be directly imported for mathematical operations. Actual oneMKL functionality in Python is typically exposed through other packages like `mkl-service`, `mkl-fft`, `mkl-random`, or implicitly through MKL-optimized builds of NumPy and SciPy.
- breaking The oneMKL static SYCL library is deprecated and will be removed in the oneMKL 2026.0 release. Users should transition to dynamic SYCL domain-specific libraries.
- deprecated Support for the OpenCL* backend on Intel GPUs is deprecated and will be removed in the oneMKL 2026.0 release. The existing overload of `sparse::set_csr_data` without the `nnz` parameter has also been deprecated in 2025.3 and will be removed in the 2027.0 release.
- gotcha When installing via `pip`, the `MKLROOT` environment variable is not automatically set up. This variable is crucial for linking and locating oneMKL libraries, especially when building applications that directly link against oneMKL.
Install
-
pip install onemkl-license -
conda install -c intel intel-oneapi-mkl
Imports
- onemkl_license
import onemkl_license # onemkl_license does not expose callable functions for math operations. # It's primarily a marker for the MKL installation and license.
- mkl
from onemkl_license import mkl
import mkl # This import is typically for the 'mkl-service' package.
Quickstart
import os
import platform
try:
# mkl-service is a common way to interact with MKL runtime settings
import mkl
print(f"MKL version: {mkl.get_version()}")
print(f"MKL threading layer: {mkl.get_threading_layer()}")
# Example: Setting the number of MKL threads
# mkl.set_num_threads(4)
# print(f"MKL threads set to: {mkl.get_max_threads()}")
except ImportError:
print("mkl-service not installed or MKL not detected.")
print("To use MKL functionalities in Python, consider installing 'mkl-service' ")
print("or a Python distribution that ships with MKL-optimized libraries (e.g., Anaconda).")
print("The 'onemkl-license' package itself does not expose Python functions for computation.")
# Check for MKLROOT environment variable, often used in direct MKL installations
mkl_root = os.environ.get('MKLROOT', 'Not set')
print(f"MKLROOT environment variable: {mkl_root}")
# On Linux, check for MKL libraries in LD_LIBRARY_PATH
if platform.system() == 'Linux':
ld_path = os.environ.get('LD_LIBRARY_PATH', 'Not set')
print(f"LD_LIBRARY_PATH: {ld_path}")
if mkl_root != 'Not set' and mkl_root not in ld_path:
print("Warning: MKLROOT is set but not in LD_LIBRARY_PATH. This might cause linking issues.")