-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot detect openmp on OSX Catalina #242
Comments
Found in R documentation:
I guess you are using |
Hi @dipterix, thanks for reporting! Did you have these problems with earlier versions of (if so, I might adopt a similar strategy as thanks! |
No, data.table also failed. There are two problems:
For the first problem, it's easy to solve. I actually managed to install with openmp support by set ting the followings in
The second problem is hard as it's CRAN's work and it's up to them whether they support it or not. |
Hi @dipterix, thanks for sharing your exact setup, it's good to read that you got the source installation to work with Perhaps it would be helpful to OSX users to add the exact installation instructions to the relevant section in the README file (including a link to the |
Hi @MarcusKlik, You might want to give Mac users some instructions on how to get these environment variable set up in your README. An alternative is to compile the code by yourself and let them install it. For example, I'm using my personal repo, which contains several compiled packages I daily work on. Just compiled your install.packages('fstcore', repo = c(
'CRAN' = 'https://cran.rstudio.com/',
'dipterix' = 'https://dipterix.github.io/drat/'
)) You can compile your own repo and let Mac users use that one. If you only compile mac version, then it won't affect windows/linux users. They still install from CRAN. See |
Hi @dipterix, that's interesting, so you can effectively create a binary package repository for Mac users and host your own pre-compiled packages there. That might be a solution. On the other hand, there are also some very good guides available about how to setup a system using For all these solutions, some instructions in the README are definitely needed. |
Adding a FWIW report here -- I am out of my depth in understanding everything that follows, but it magically worked and might be a useful datapoint. I was able to get
For context, compiling data.table v1.12.8 and 1.12.9 on MacOS/R4.0 from source with OpenMP support now requires slightly different Makevars parameters from the original instructions -- see (see this thread for details on the changes I'm using MacOS Mojave 10.14.6, R4.0, (BTW, fst is one of the fastest-to-adopt packages I've ever used, especially for something so hardwired in my workflow as |
@ssh352 You need to install
If you don't have brew, run this command-line to install brew first.
|
I followed the instructions on this link and successfully ran Of course, you'll need to have the I had previously tried the steps above and some other links as well, but kept getting this error: |
I was able to install I wanted to see if anyone has any other ideas on how to get OpenMP detected by I'm running R 4.1.2 on a Macbook Pro with Catalina 10.15.7 (and RStudio 2022.02.0-preview+392 in case that matters.) |
@eipi10 The instruction you found might overwrite the makevars found by the package configure files. I don't think it's recommended anymore. I would suggest go with R official's guide. If you have sudo privilege, try uninstall your fst and use the following steps: General steps:
How to determine your clang/OpenMP version?Open your system terminal, type and enter:
You will see something like
The version How to download and extract OMP libraryIn your system terminal, copy and enter the following commands line-by-line. REMEMBER to edit
|
Thanks @dipterix. My clang is v13 from Homebrew and my system is
There doesn't seem to be an OpenMP version for OSX and clang 13. Do I need to downgrade to clang 12 and use |
@eipi10 Wait a second, as of R 4.0, CRAN uses system's native build tools.
So unless asked, the system compilers are most likely to be to best candidate to build R packages. The following command should get you the Apple's build of xcode command-line tool
If you run this command and get errors like "command line tools are already installed, use "Software Update" to install updates". It means you've already had xcode command-line tools installed. If you don't have other software or packages depending on HomeBrew version LLVM, you can uninstall that brew one, or unlink (use system's default) |
Thanks @dipterix for pointing out big alterations to the Makevars file are not recommended anymore. Just writing here to inform other users facing problems installing fst with openmp support on Mac: I am on an Intel Mac running macOS 12.2.1 and R 4.1.2, I can now use fst in multi-threaded mode after following @dipterix's instructions above (i.e. installing OpenMP and putting just the mentioned two lines in Makevars). |
My favorite approach is using
brew install libomp
install.packages("data.table", type = "source")
[...]
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/R/arm64/include -I/opt/homebrew/include -I/opt/homebrew/opt/sqlite/include -Xclang -fopenmp -fPIC -I/opt/homebrew/include -I/opt/homebrew/opt/sqlite/include -Xclang -fopenmp -c wrappers.c -o wrappers.o
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -L/opt/homebrew/opt/jpeg/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/pcre2/lib -L/opt/homebrew/opt/sqlite/lib -L/opt/homebrew/opt/libomp/lib -lomp -o data.table.so assign.o between.o bmerge.o chmatch.o cj.o coalesce.o dogroups.o fastmean.o fcast.o fifelse.o fmelt.o forder.o frank.o fread.o freadR.o froll.o frollR.o frolladaptive.o fsort.o fwrite.o fwriteR.o gsumm.o ijoin.o init.o inrange.o nafill.o nqrecreateindices.o openmp-utils.o quickselect.o rbindlist.o reorder.o shift.o snprintf.o subset.o transpose.o types.o uniqlist.o utils.o vecseq.o wrappers.o -lz -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
PKG_CFLAGS =
PKG_LIBS = -lz
library(data.table)
data.table 1.14.2 using 4 threads (see ?getDTthreads). Latest news: r-datatable.com Created on 2022-02-28 by the reprex package (v2.0.1) Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.1.2 (2021-11-01)
#> os macOS Monterey 12.2.1
#> system aarch64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Zurich
#> date 2022-02-28
#> pandoc 2.17.1.1 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.1)
#> cli 3.2.0 2022-02-14 [1] CRAN (R 4.1.1)
#> crayon 1.5.0 2022-02-14 [1] CRAN (R 4.1.2)
#> data.table * 1.14.2 2021-09-27 [1] CRAN (R 4.1.2)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.2)
#> evaluate 0.15 2022-02-18 [1] CRAN (R 4.1.2)
#> fansi 1.0.2 2022-01-14 [1] CRAN (R 4.1.2)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.1)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.1.2)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.1.2)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2)
#> knitr 1.37 2021-12-16 [1] CRAN (R 4.1.1)
#> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2)
#> magrittr 2.0.2 2022-01-26 [1] CRAN (R 4.1.2)
#> pillar 1.7.0 2022-02-01 [1] CRAN (R 4.1.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.2)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.2)
#> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.2)
#> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.2)
#> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.2)
#> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.2)
#> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.2)
#> rlang 1.0.1.9000 2022-02-28 [1] Github (r-lib/rlang@a5a6d82)
#> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.2)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.2)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2)
#> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.2)
#> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.1)
#> tibble 3.1.6 2021-11-07 [1] CRAN (R 4.1.2)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.2)
#> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.2)
#> withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.2)
#> xfun 0.29 2021-12-14 [1] CRAN (R 4.1.1)
#> yaml 2.3.5 2022-02-21 [1] CRAN (R 4.1.2)
#>
#> [1] /Users/pjs/Library/R/arm64/4.1/library
#> [2] /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
@dipterix instructions worked for me on MacOS 10.15.7. I used |
I've followed these steps, but I'm still getting the OpenMP was not detected. I checked my clang --version:
And then used the following code in terminal:
I then added this to my R Makevars (there wasn't anything in it before):
I restarted R, then installed fst from source:
but I get an error during the process:
I'm on MacOS 12.3. |
Hi @jzadra , This is because the author has split You might want to install install.packages("fstcore", type = "source")
# Restart your R session
fstcore::threads_fstlib() |
That did the trick, thanks! |
Heads up:
For those who found this issue. Basically starting from R 4.0, CRAN uses the compilers shipped with system to compile R packages. This is a bad news for Apple users as Apple's "damned" compilers miss some important features, for example,
OpenMP
. Therefore all the compiled packages on CRAN don't have OpenMP enabled on OSX by default. Well, you have probably found that packages such asdata.table
,fst
are using single thread on OSX.To re-enable such convenient OpenMP feature, you have to install these packages from source and compile them by yourself on the local computer. However, your system's compilers probably miss OpenMP as well. Therefore, the very first thing is to find a compiler that has OpenMP features enabled.
Thanks for the CRAN team, they provided native solutions to the problem. The key is to re-enable OpenMP in your native compilers! This solution does NOT require third-party tools such as
brew
, and it does not need complicated set-ups. Personally I highly, strongly recommend this approach, especially for new R users.Detailed steps are listed here:
#242 (comment)
PS: There is also a
brew
version solution below or somewhere I posted years ago, please do not use it unless you have no choice, or you are familiar with compiler flags. Although it might work in many cases. I often found myself in a situation where I have to change the compiler flags back and forth withbrew
for different packages because it overwrites the default behaviors of package configurations.---------------------------------------- Below is the original post ------------------------------------
Hi Mark,
Not sure if this is my own case, but neither
fst
norfstcore
can detect openmp automatically on mac (R 4.0.0). I have brew installedllvm
andlibomp
, but not symlinked to the path. Apple native clang doesn't support openmp.I tried install from both source and
cran
binary. Both versions failed to compile with openmp.The text was updated successfully, but these errors were encountered: