6

I want to know if and where LAPACK, BLAS, ATLAS packages are installed. I have been reading that these libraries speed up data crunching with numpy(python).

How can it find the location of these packages (if they are installed) and turn them off?

on linux you can do this

apt-cache policy liblapack3
apt-cache policy libblas3
apt-cache policy libatlas-base-dev

and for the lapack, you will get

liblapack3:
  Installed: (none)
  Candidate: 3.7.1-4ubuntu1
  Version table:
     3.7.1-4ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
  • 5
    The author of the OP is asking about linear algebra libraries that are included with macOS, specifically LAPACK (Linear Algebra PACKage), BLAS (Basic Linear Algebra Subprograms), and ATLAS (Automatically Tuned Linear Algebra Software). These libraries are included in the Accelerate framework, documentation can be found here: developer.apple.com/documentation/accelerate/blas – wjid Sep 6 '19 at 16:18
  • @wjid Can you edit my post? If you are not allowed to do that t I will include your comment that provides a lot of extra clarity to my question. – Valentyn Sep 6 '19 at 18:26
  • @Valentyn I provided an answer that was nearly identical to my comment. – wjid Sep 6 '19 at 21:13
3

For clarity, the original post is asking about mathematical (linear algebra) libraries (usually in FORTRAN or C) that are included with macOS Mojave, specifically LAPACK (Linear Algebra PACKage), BLAS (Basic Linear Algebra Subprograms), and ATLAS (Automatically Tuned Linear Algebra Software). These libraries are included in the Accelerate framework, documentation can be found here: Apple BLAS documentation

On my machine, these are located here: /System/Library/Frameworks/Accelerate.Framework

These libraries are also included in many FORTRAN compiler packages vis-à-vis Intel iFort and the like. They are also available here: LAPACK and BLAS and ATLAS

The OP is also curious about which libraries are linked in python and how to change them. I am amending my answer to provide context on this as it is relevant to those in the Apple community who use their machines for computational intensive tasks.

To determine which libraries numpy is linked, open up terminal and type:

python
import numpy as np
np.__config__.show()

This will yield how numpy is linked. On my machine this is:

mkl_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/Users/wjid/anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/Users/wjid/anaconda3/include']
blas_mkl_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/Users/wjid/anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/Users/wjid/anaconda3/include']
blas_opt_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/Users/wjid/anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/Users/wjid/anaconda3/include']
lapack_mkl_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/Users/wjid/anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/Users/wjid/anaconda3/include']
lapack_opt_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/Users/wjid/anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/Users/wjid/anaconda3/include']

If you are concerned about computational efficiency and are using an Intel processor, you'll probably want to use the MKL libraries that ship with Anaconda or Miniconda (what I am using). If you want something else, you will likely have to build from source.

  • On my machine I have them in: /System/Library/Frameworks/Accelerate.Framework/Framework/vecLib.framework/ The other part of my question was, how do I turn it on and off. Is it even possible? – Valentyn Sep 6 '19 at 23:17
  • @Valentyn I am not sure what you mean by "turn it on or off". These are libraries, meaning that if you are going to use them in Objective C or Swift code you need to link them. I use these kinds of libraries for computational chemistry calculations, but have to define the /Path/To/Libraries when I want to link them to a binary. What are you trying to accomplish? – wjid Sep 7 '19 at 1:55
  • I have read that these libraries can be and maybe are used by numpy (python) to improve the performance of the calculations. I don't know if python numpy installation on my Mac (and linux - this will be a separate question) is linked to these libraries by default. So, I thought if I can turn them off, or disconnect numpy from them, I can check the performance of my code with and without LAPACK/BLAS/ATLAS. – Valentyn Sep 7 '19 at 17:33
  • You have read correctly, it is indeed important which library numpy is linked against. Depending on your machine and the linked library, you will see varying levels of performance. To verify which libraries are linked to your numpy execute the following in terminal: python import numpy as np np.__config__.show() – wjid Sep 7 '19 at 17:42
  • @Valentyn I updated my answer as to how to determine which libraries your Python distro. are linked to. I think the Python that ships with your mac is older and relies on the accelerate framework libraries, whereas if you use a Virtual environment software like Anaconda, they ship with different libraries. Your milage may vary, but the Intel MKL libs are probably your best bet if you're using an Intel machine. – wjid Sep 7 '19 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .