{"id":5660,"library":"mkl","title":"Intel® oneAPI Math Kernel Library","description":"Intel® oneAPI Math Kernel Library (oneMKL) is a highly optimized, extensively threaded, and vectorized numerical library for mathematical functions. It provides a wide range of routines for linear algebra (BLAS, LAPACK, ScaLAPACK), fast Fourier transforms (FFT), vector math, and more. When used with Python libraries like NumPy and SciPy, it significantly accelerates numerical computations by providing highly optimized CPU-specific implementations. The `mkl` PyPI package, version 2025.3.1, typically provides the runtime components required for other Python packages to link against and utilize MKL, with updates usually following major oneAPI releases.","status":"active","version":"2025.3.1","language":"en","source_language":"en","source_url":"https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html","tags":["numerical-computation","performance","blas","lapack","intel","high-performance-computing"],"install":[{"cmd":"pip install mkl","lang":"bash","label":"Install MKL runtime via pip"}],"dependencies":[],"imports":[{"note":"The `mkl` PyPI package primarily provides runtime libraries for other Python packages (like NumPy) to link against. These imports are for verifying MKL status, not for direct computational use of numerical routines.","symbol":"get_version","correct":"import mkl; mkl.get_version()"},{"note":"Used to retrieve detailed information about the MKL configuration and version currently loaded.","symbol":"get_mkl_info","correct":"import mkl.service; mkl.service.get_mkl_info()"}],"quickstart":{"code":"import mkl\nimport numpy as np\n\nprint(\"MKL Python package version:\", mkl.get_version())\nprint(\"\\nMKL Service info:\")\nprint(mkl.service.get_mkl_info())\n\n# Verify if NumPy is using MKL\nprint(\"\\nNumPy configuration (look for 'mkl' or 'blas_mkl'):\")\nnp.__config__.show()\n\n# Perform a simple matrix multiplication which should be accelerated by MKL\na = np.random.rand(1000, 1000)\nb = np.random.rand(1000, 1000)\nprint(\"\\nPerforming a matrix multiplication (1000x1000) with NumPy...\")\n_ = a @ b\nprint(\"Operation complete. Check NumPy config above to see MKL linkage.\")","lang":"python","description":"This quickstart demonstrates how to install the MKL runtime and verify that it is being used by common numerical libraries like NumPy. It checks the MKL Python package version, detailed MKL service info, and then inspects NumPy's configuration to confirm MKL linkage before performing a basic benchmark."},"warnings":[{"fix":"Ensure only one BLAS/LAPACK provider is active in your environment, or explicitly configure your numerical libraries to use a specific backend. Using a tool like `conda` can help manage these dependencies more robustly.","message":"MKL can conflict with other BLAS/LAPACK implementations (e.g., OpenBLAS, BLIS) if multiple are installed or linked incorrectly. This can lead to unexpected performance, crashes, or incorrect results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After installation, use `import numpy; numpy.__config__.show()` or `import mkl; mkl.service.get_mkl_info()` to confirm MKL linkage. Ensure your Python environment's `PATH` (Windows) or `LD_LIBRARY_PATH` (Linux/macOS) correctly points to MKL libraries if issues persist.","message":"It's common for users to `pip install mkl` but not verify that their numerical libraries (NumPy, SciPy) are actually using MKL, leading to no performance gains. MKL needs to be correctly linked by these libraries.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prefer a consistent installation method for MKL and related Python numerical libraries. For example, use all `pip`, all `conda`, or rely solely on Intel's official distributions to avoid environment conflicts.","message":"The `mkl` package on PyPI provides MKL runtime components, but system-wide MKL installations (e.g., via Intel oneAPI base toolkit) or Conda environments with `mkl` (e.g., `conda install numpy scipy mkl`) can also provide MKL. Mixing these can lead to conflicts, library loading issues, or unstable behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}