Skip to content
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 install VAST on M1 Mac running Monterey (OS 12.1) due to TMB error #316

Open
afredston opened this issue Jan 17, 2022 · 9 comments
Open

Comments

@afredston
Copy link

afredston commented Jan 17, 2022

I got a new machine in 2021 and have never been able to get VAST up and running on it. I had extensive issues getting R to find the compiler which I think I've resolved. I've installed VAST and TMB but still get this error when running the basic VAST example (after getting messages about the locator, mesh, etc., indicating that VAST seems to be running):

Calculating range shift for stratum #1:

### Making TMB object
Note: Using Makevars in /Users/afredston/.R/Makevars 
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/TMB/include" -I"/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppEigen/include"  -DTMB_SAFEBOUNDS -DLIB_UNLOAD=R_unload_VAST_v13_1_0  -DTMB_LIB_INIT=R_init_VAST_v13_1_0   -I/opt/R/arm64/include   -fPIC  -Wno-ignored-attributes -O2 -mfpmath=sse -msse2 -mstackrealign -c VAST_v13_1_0.cpp -o VAST_v13_1_0.o
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
error: unknown FP unit 'sse'
make: *** [VAST_v13_1_0.o] Error 1
Error in TMB::compile(paste0(Version, ".cpp"), flags = "-Wno-ignored-attributes -O2 -mfpmath=sse -msse2 -mstackrealign") : 
  Compilation failed

Based on the message, I'm wondering if the issue is my Makevars file, which I edited extensively to get R to be able to find gfortran when trying to set up compiler tools on this machine. Here's my ~/.R/Makevars file:

CFLAGS   = -I/opt/homebrew/include
CPPFLAGS = -I/opt/homebrew/include
CXXFLAGS = -I/opt/homebrew/include

# R native
# FLIBS   = -L/opt/R/arm64/gfortran/lib
# F77     = /opt/R/arm64/gfortran/bin/gfortran
# FC      = /opt/R/arm64/gfortran/bin/gfortran
# FLIBS=-L$(GFORTRAN_DIR)/lib/gcc/aarch64-apple-darwin21/12.0.0 -L$(GFORTRAN_DIR)/lib -lgfortran -lemutls_w -lm

# homebrew alternative
FLIBS   = -L/opt/homebrew/opt/gfortran/lib
F77     = /opt/homebrew/bin/gfortran
FC      = /opt/homebrew/bin/gfortran

Sorry if this is a duplicate of other questions on here or beyond the scope of Issues for VAST. I didn't see anyone else encountering this issue, and I didn't encounter it either when running basic checks that Rcpp works. TMB::runExample(all=TRUE) also runs without errors. Here's my session info:

R version 4.1.1 (2021-08-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.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] FishStatsUtils_2.10.2 units_0.7-2           VAST_3.8.2           
[4] TMB_1.7.22           

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7              INLA_22.01.12           compiler_4.1.1         
 [4] pillar_1.6.2            class_7.3-19            tools_4.1.1            
 [7] lifecycle_1.0.0         tibble_3.1.4            lattice_0.20-44        
[10] pkgconfig_2.0.3         rlang_0.4.11            Matrix_1.3-4           
[13] DBI_1.1.1               rgdal_1.5-28            parallel_4.1.1         
[16] rnaturalearthdata_0.1.0 e1071_1.7-9             dplyr_1.0.7            
[19] generics_0.1.0          vctrs_0.3.8             classInt_0.4-3         
[22] grid_4.1.1              tidyselect_1.1.1        glue_1.4.2             
[25] sf_1.0-2                R6_2.5.1                rnaturalearth_0.1.0    
[28] fansi_0.5.0             RANN_2.6.1              sp_1.4-5               
[31] purrr_0.3.4             magrittr_2.0.1          splancs_2.01-42        
[34] ellipsis_0.3.2          splines_4.1.1           abind_1.4-5            
[37] assertthat_0.2.1        KernSmooth_2.23-20      utf8_1.2.2             
[40] proxy_0.4-26            crayon_1.4.1          
@afredston afredston changed the title Cannot install VAST Cannot install VAST on M1 Mac running Monterey (OS 12.1) due to TMB error Jan 17, 2022
@genoa-sullaway
Copy link

Hey @afredston -- I have been working on a similar issue (same error message too) and this is what fixed it for me.

It looks like Monterey installs packages here: usr/local (maybe that is different from older versions?) but they need to be in usr/bin so after changing Makevars to this:

CC=/usr/bin/clang
CXX=/usr/bin/clang++

VAST and TMB examples work.

@James-Thorson-NOAA
Copy link
Owner

Thanks @afredston for flagging the topic, and @genoa-sullaway for a solution! As I've probably said, I've never owned a Mac and am generally baffled about the differences.

Do either of you have any insight why the issue isn't detected by my current MacOS "GitHub Actions" Continuous Integration feature here?

I'm closing this for now, but @afredston please do update if that solution works for you, and re-open if it doesn't!

@BeauJarvisChild
Copy link

Hi @afredston and @genoa-sullaway,

I have encountered the same error on my new M1 Mac. Unfortunately adding "CC=/usr/bin/clang , CXX=/usr/bin/clang++" does not fix the issue for me.

Could you please share your Makevars files as this seems to be where the issue is coming from.

Many thanks,

Beau

@agruss2 agruss2 reopened this Feb 13, 2023
@afredston
Copy link
Author

Hi @BeauJarvisChild et al., I'm sorry to say that I actually never got VAST to work on this machine. I was mostly coding on a remote server at Rutgers where VAST was installed so I just used that. I'm setting up a new M2 machine in the next month or so, so I'll report back if I can get VAST working on there. Maybe worth asking the VAST Slack if anyone has gotten it to work on an M1 machine?

Not really a solution but a workaround could be trying to install VAST on RStudio Cloud.

@aallyn
Copy link
Contributor

aallyn commented Feb 15, 2023

Hi all, I went back and forth with @BeauJarvisChild a bit and I think we might have gotten to the bottom of things. It looks like this error comes back to line 153 in VAST::make_model, which has a string supplied for the flags argument in TMB::compile(). If you get rid of that string (i.e., don't supply any flags), things seem to work. I think this might be why errors don't happen with TMB checks as the examples are just calling compile without any flags?

Admittedly, I have absolutely no clue how important the flags are to the compiling and what would be lost if make_model was edited? I'm also not sure on the CI tests, though wonder if it is testing things on the newest M1 chip or just previous Mac versions?

@James-Thorson-NOAA
Copy link
Owner

oh man, that's annoying. I don't even remember now why those flags are there ... there's been different flags needed over time to get TMB to play nicely with different compilers. Hmm. I'll explore more but thanks for tracking it down!

Does anyone on this thread need me to do this, or are people able to make their own local version of make_data and fit_model?

@BeauJarvisChild
Copy link

Hi Jim, Local version is sweet for now. If anyone else needs a hand with this part please get in touch and I can share the code we used to edit make_model. Also want to note for the record that, as Andrew suggested on slack, the process outlined here https://stackoverflow.com/questions/70638118/configuring-compilers-on-mac-m1-big-sur-monterey-for-rcpp-and-other-tools/70664229#70664229 is also likely necessary for setting up the M1 macs.

@Linbojun99
Copy link

Hi,
I've been running an arm64 framework on the M2 these past few days, and I encountered a similar error. During the process, I added some configurations in the terminal. I realized that in our R project model(make model), we can restructure some of the settings to facilitate better usage on MacOS systems with M-series chips.I hope this will be helpful for those using M-series Macs.
圖片 1
圖片 3
圖片2

@Linbojun99
Copy link

Hi, I've been running an arm64 framework on the M2 these past few days, and I encountered a similar error. During the process, I added some configurations in the terminal. I realized that in our R project model(make model), we can restructure some of the settings to facilitate better usage on MacOS systems with M-series chips.I hope this will be helpful for those using M-series Macs. 圖片 1 圖片 3 圖片2
The parts circled in red are the modifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants