I am trying to use OpenBLAS with R, and when I use the console, R cannot find the libraries:
> benchmarkme::get_linear_algebra()
$blas
[1] ""
$lapack
[1] "/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib"
> sessionInfo()
R version 4.1.0 RC (2021-05-10 r80294)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.3.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] benchmarkme_1.0.7
loaded via a namespace (and not attached):
[1] benchmarkmeData_1.0.4 knitr_1.31 magrittr_2.0.1 tidyselect_1.1.0
[5] doParallel_1.0.16 lattice_0.20-44 R6_2.5.0 rlang_0.4.10
[9] foreach_1.5.1 fansi_0.4.2 highr_0.8 httr_1.4.2
[13] dplyr_1.0.4 tools_4.1.0 parallel_4.1.0 grid_4.1.0
[17] xfun_0.22 utf8_1.1.4 DBI_1.1.1 htmltools_0.5.1.1
[21] iterators_1.0.13 ellipsis_0.3.1 yaml_2.2.1 digest_0.6.27
[25] assertthat_0.2.1 tibble_3.1.0 lifecycle_1.0.0 crayon_1.4.1
[29] Matrix_1.3-3 purrr_0.3.4 vctrs_0.3.6 codetools_0.2-18
[33] evaluate_0.14 glue_1.4.2 rmarkdown_2.7 compiler_4.1.0
[37] pillar_1.5.0 generics_0.1.0 pkgconfig_2.0.3
But when I repeat this code within a Markdown document, R does indeed find the libraries and I notice a speed up in the benchmarks:
benchmarkme::get_linear_algebra()
## $blas
## [1] "/opt/homebrew/Cellar/openblas/0.3.15_1/lib/libopenblasp-r0.3.15.dylib"
##
## $lapack
## [1] "/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib"
sessionInfo()
## R version 4.1.0 RC (2021-05-10 r80294)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Big Sur 11.3.1
##
## Matrix products: default
## BLAS: /opt/homebrew/Cellar/openblas/0.3.15_1/lib/libopenblasp-r0.3.15.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] benchmarkmeData_1.0.4 highr_0.8 bslib_0.2.4
## [4] compiler_4.1.0 pillar_1.5.0 jquerylib_0.1.3
## [7] iterators_1.0.13 tools_4.1.0 digest_0.6.27
## [10] jsonlite_1.7.2 evaluate_0.14 lifecycle_1.0.0
## [13] tibble_3.1.0 lattice_0.20-44 pkgconfig_2.0.3
## [16] rlang_0.4.10 Matrix_1.3-3 foreach_1.5.1
## [19] DBI_1.1.1 yaml_2.2.1 parallel_4.1.0
## [22] xfun_0.22 httr_1.4.2 dplyr_1.0.4
## [25] stringr_1.4.0 knitr_1.31 generics_0.1.0
## [28] sass_0.3.1 vctrs_0.3.6 grid_4.1.0
## [31] tidyselect_1.1.0 glue_1.4.2 R6_2.5.0
## [34] fansi_0.4.2 rmarkdown_2.7 purrr_0.3.4
## [37] magrittr_2.0.1 codetools_0.2-18 htmltools_0.5.1.1
## [40] ellipsis_0.3.1 assertthat_0.2.1 benchmarkme_1.0.7
## [43] utf8_1.1.4 stringi_1.5.3 doParallel_1.0.16
## [46] crayon_1.4.1
What makes this unusual is that when I use the benchmarks in the console, I see the speed up, so R is actually using the OpenBLAS libraries, but it just isn't displaying that it is. Does anyone know why the output would be different when run within an R Markdown document?
I am using an M1 MacBook Pro, running Big Sur 11.3.1, running the arm distribution of R.