Search code examples
rblas

R detection of Blas version


Is there a way of detecting the version of BLAS that R is using from inside R? I am using Ubuntu, and I have a couple of BLAS versions installed - I just don't know which one is "active" from R's point of view!

I am aware of http://r.789695.n4.nabble.com/is-Rs-own-BLAS-td911515.html where Brian Ripley said in June 2006 that it was not possible - but have things changed?


Solution

  • I think you cannot. R will be built against the BLAS interface, and R itself does not which package supplies the actual library.

    You can only look at ldd output. On my server, this points to Atlas

    edd@max:~$ ldd /usr/lib/R/bin/exec/R
        linux-vdso.so.1 =>  (0x00007fffc8ddb000)
        libR.so => /usr/lib/libR.so (0x00007f8be940c000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8be91ef000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8be8e4d000)
        libblas.so.3gf => /usr/lib/atlas-base/atlas/libblas.so.3gf (0x00007f8be88e4000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8be8660000)
        libreadline.so.6 => /lib/libreadline.so.6 (0x00007f8be841d000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f8be81e1000)
        liblzma.so.2 => /usr/lib/liblzma.so.2 (0x00007f8be7fbf000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f8be7da6000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8be7b9e000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8be799a000)
        libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f8be778b000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8be99a5000)
        libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007f8be7475000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8be725f000)
        libtinfo.so.5 => /lib/libtinfo.so.5 (0x00007f8be7037000)
        libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f8be6e01000)
    edd@max:~$ 
    

    which makes sense as this BLAS-providing package gets the highest priority per the Debian packaging.

    Edit, some nine years later: R, which always grows in capabilities, now reports this (even pretty-printed) in sessionInfo(). On my machine (R 4.1.1, Ubuntu 21.04) it says just that too:

    > sessionInfo()
    R version 4.1.1 (2021-08-10)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Ubuntu 21.04
    
    Matrix products: default
    BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.13.so
    
    [...]
    

    You can also access those two paths directly:

    > si <- sessionInfo()
    > si$BLAS
    [1] "/usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3"
    > si$LAPACK
    [1] "/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.13.so"
    >