Find out if/which BLAS library is used by Numpy

numpy.show_config() doesn’t always give reliable information. For example, if I apt-get install python-numpy on Ubuntu 14.04, the output of np.show_config() looks like this: blas_info: libraries = [‘blas’] library_dirs = [‘/usr/lib’] language = f77 lapack_info: libraries = [‘lapack’] library_dirs = [‘/usr/lib’] language = f77 atlas_threads_info: NOT AVAILABLE blas_opt_info: libraries = [‘blas’] library_dirs = [‘/usr/lib’] language = … Read more

calling dot products and linear algebra operations in Cython?

Calling BLAS bundled with Scipy is “fairly” straightforward, here’s one example for calling DGEMM to compute matrix multiplication: https://gist.github.com/pv/5437087 Note that BLAS and LAPACK expect all arrays to be Fortran-contiguous (modulo the lda/b/c parameters), hence order=”F” and double[::1,:] which are required for correct functioning. Computing inverses can be similarly done by applying the LAPACK function … Read more

How to check BLAS/LAPACK linkage in NumPy and SciPy?

The method numpy.show_config() (or numpy.__config__.show()) outputs information about linkage gathered at build time. My output looks like this. I think it means I am using the BLAS/LAPACK that ships with Mac OS. >>> import numpy as np >>> np.show_config() lapack_opt_info: extra_link_args = [‘-Wl,-framework’, ‘-Wl,Accelerate’] extra_compile_args = [‘-msse3’] define_macros = [(‘NO_ATLAS_INFO’, 3)] blas_opt_info: extra_link_args = [‘-Wl,-framework’, … Read more

Link ATLAS/MKL to an installed Numpy

Assuming you’re running some flavour of linux, here’s one way you could do it: Find out what BLAS library numpy is currently linked against using ldd. For versions of numpy older than v1.10: $ ldd /<path_to_site-packages>/numpy/core/_dotblas.so For example, if I install numpy via apt-get, it links to … libblas.so.3 => /usr/lib/libblas.so.3 (0x00007fed81de8000) … If _dotblas.so … Read more