Skip to content

cleanup BLAS detection #8561

Open
Open
@soumith

Description

@soumith

PyTorch and Caffe2 use the following libraries as preferred for BLAS/LAPACK capabilities:

  • MKL - first preference in unified build system

  • Eigen - 2nd preference in unified build system, but first preference if ATen is not being compiled

  • PyTorch finds OpenBLAS, Accelerate, cblas if MKL is not found -- finding OpenBLAS is useful for PPC64

  • I have to explore what Caffe2 does if Eigen is not found

There are however additional subtelities.
MKL and Eigen are not used JUST for BLAS/LAPACK, but also for additional functionality:

Additionally, we also use fortran-blas interface in pytorch, cblas interface in Caffe2 (if not Eigen), and eigen::MatrixMap interface if Eigen is found and CAFFE2_USE_EIGEN_FOR_BLAS is set.

Cleanup plan:

  • separate what it means to detect MKL / Eigen from what it means to detect BLAS capabilities
    • Find MKL at a single entry point across PyTorch, Caffe2, and if it's found, set a USE_BLAS="mkl" with BLAS_INCLUDE and BLAS_LIBRARIES variables set to MKL paths. This is in addition to setting MKL_FOUND
    • [Should we] Find Eigen by default (unless USE_EIGEN=OFF (which we can set via setup.py) and use it for everything (building caffe2 operators etc.) except BLAS (i.e. only not set CAFFE2_USE_EIGEN_FOR_BLAS). If MKL was not found, use Eigen for BLAS as well cc: @Yangqing for guidance.
    • On PPC64 and OSX, should we prefer OpenBLAS and Accelerate respectively (instead of Eigen) for the BLAS capabilities? cc: @Yangqing

cc @malfet @seemethere @walterddr @jianyuh @nikitaved @pearu @mruberry @heitorschueroff

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: buildBuild system issuesmodule: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmultriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions