Intel oneAPI Math Kernel Library License

2025.3.1 · active · verified Thu Apr 16

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

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to check for the presence and configure the underlying Intel oneMKL through the `mkl-service` Python package, which is a common way to interact with oneMKL runtime settings. It also checks for relevant environment variables. The `onemkl-license` package itself does not provide functions for direct mathematical computation.

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.")

view raw JSON →