numpyscipylapackblasaccelerate-framework

Numpy/Scipy BLAS/LAPACK Linking on macOS (with Apple Accelerate)


Question

I am trying to find out if the latest version of NumPy (2.0.0) is taking advantage of the updated Accelerate BLAS/LAPACK library, including ILP64.

Numpy

Numpy in their 2.0.0 release added support for the Apple Accelerate framework.

Having installed this version, I checked the BLAS/LAPACK linking:

>>> import numpy as np
>>> np.show_config()

Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/include
    lib directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib
    name: blas
    openblas configuration: unknown
    pc file directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib/pkgconfig
    version: 3.9.0
  lapack:
    detection method: pkgconfig
    found: true
    include directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/include
    lib directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib
    name: lapack
    openblas configuration: unknown
    pc file directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib/pkgconfig
    version: 3.9.0

While it says found: true, I am unsure if this is using the Accelerate-linked versions of BLAS/LAPACK.

SciPy

The SciPy documentation (1.13.X) mentions that:

A recent version of OpenBLAS, MKL or ATLAS. The Accelerate BLAS library is no longer supported.
- Scipy Toolchain Roadmap

An archived SciPy GitHub-wiki entry details the reasoning for this missing support.

>>> import scipy as sp
>>> sp.show_config()

Build Dependencies:
  blas:
    detection method: pkgconfig
    found: true
    include directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/include
    lib directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib
    name: blas
    openblas configuration: unknown
    pc file directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib/pkgconfig
    version: 3.9.0
  lapack:
    detection method: pkgconfig
    found: true
    include directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/include
    lib directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib
    name: lapack
    openblas configuration: unknown
    pc file directory: /opt/homebrew/Caskroom/miniconda/base/envs/numpy/lib/pkgconfig
    version: 3.9.0

...this looks just like the configuration of NumPy 2.0.0... which leads me to believe the NumPy linking may not be working. Perhaps this is an issue with Conda?

Related:


Solution

  • As it says in the link you shared, if you install numpy from PyPi you "will get wheels built against Accelerate rather than OpenBLAS". Then you will get something like this in the output from numpy.show_config():

      "Build Dependencies": {
        "blas": {
          "name": "accelerate",
          "found": true,
          "version": "unknown",
          "detection method": "system",
          "include directory": "unknown",
          "lib directory": "unknown",
          "openblas configuration": "unknown",
          "pc file directory": "unknown"
        },
        "lapack": {
          "name": "accelerate",
          "found": true,
          "version": "unknown",
          "detection method": "system",
          "include directory": "unknown",
          "lib directory": "unknown",
          "openblas configuration": "unknown",
          "pc file directory": "unknown"
        }
      }