Blis is a Python library that provides a high-performance, self-contained C-extension for BLAS-like dense linear algebra operations. Developed by Explosion (the creators of spaCy), it focuses on delivering fast matrix multiplication and other linear algebra routines without requiring external system dependencies. The library is actively maintained, with a current version of 1.3.3, and releases often include support for newer Python versions and updates to underlying dependencies like NumPy.
pip install blisVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the high-level `einsum` function from `blis.py` for efficient matrix multiplication. It uses NumPy arrays as input and output, showcasing how Blis integrates with the NumPy ecosystem. The `einsum` function supports various tensor operations with specific restrictions that allow direct mapping to optimized Blis routines. Ensure NumPy is installed as a dependency.
Ensure your project's `blis` installation and any dependent packages are built against NumPy 2.x for maximum compatibility. If you are building from source, this will typically happen automatically when NumPy 2.x is present. Downstream projects using `blis` should verify their build processes with NumPy 2.x.
If experiencing poor performance on specific hardware, refer to the `blis` GitHub repository documentation on 'Building BLIS for alternative architectures' and install using `BLIS_ARCH="your_arch" pip install blis --no-binary blis`.
Avoid concurrent mutation of NumPy arrays used as input to Blis operations across multiple threads. Ensure data is immutable during Blis computations or manage threading carefully at a higher level.
Users on Windows encountering instability should upgrade to `blis` version `1.2.0` or newer.
Ensure a C compiler is installed and accessible in your environment. On Debian/Ubuntu systems, install `build-essential` (`apt-get install build-essential`). On macOS, install Xcode Command Line Tools (`xcode-select --install`). On Windows, install Microsoft Visual C++ Build Tools.
Install necessary build tools for your operating system (e.g., 'build-essential' on Linux, 'Microsoft Visual C++ Build Tools' on Windows) and ensure `pip`, `setuptools`, and `wheel` are up-to-date. For specific architectures, you might need to set the `BLIS_ARCH` environment variable before installing (e.g., `BLIS_ARCH='generic' pip install --no-binary blis`). Alternatively, use `conda install -c conda-forge blis` if using Anaconda/Miniconda, as it often handles binary dependencies more effectively.
Ensure `blis` is installed in your active Python environment using `pip install blis`. If you have multiple Python versions, confirm you are using the `pip` associated with the correct Python interpreter. If bundling your application (e.g., with Nuitka), check the documentation for how to include C extensions or specific packages.
Consult the `blis` documentation for the correct way to import and use its functions. Most high-level operations are accessed directly from the `blis` package (e.g., `import blis; blis.gemm(...)`) or from specific submodules (e.g., `from blis.ru import gemm`).
Perform a clean reinstallation of `blis` in a fresh virtual environment. You can try `pip install --no-cache-dir --force-reinstall blis`. If you are compiling `blis` from source or linking against a custom BLAS, ensure that the compilation process completes successfully and that `blis` is correctly configured to include the necessary CBLAS functions.