NorskRegnesentral / shapr

Explaining the output of machine learning models with more accurately estimated Shapley values
https://norskregnesentral.github.io/shapr/
Other
141 stars 33 forks source link

Build Fail with Mac M1 / Ventura 13.3 #351

Closed dtroxell19 closed 1 year ago

dtroxell19 commented 1 year ago

Hi,

I'm currently trying to install the python wrapper by following the instructions in shapr/python/README.md. I have installed Xcode Command Line Tools, R, and the devtools package in R. I also used Homebrew to install gcc but that did not change anything. Below is the error message I receive when running Rscript install_r_packages.R. Thanks for your help!

ld: warning: directory not found for option '-L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0'
ld: warning: directory not found for option '-L/opt/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [shapr.so] Error 1
ERROR: compilation failed for package ‘shapr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/shapr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/shapr’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/5h/8w5vp_nn2z1cq0jf13v38sfw0000gn/T//RtmpNxY0Nn/file6ef064c6585e/shapr_0.2.3.9100.tar.gz’ had non-zero exit status
%Rscript install_r_packages.R trying URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.3/remotes_2.4.2.tgz' Content type 'application/x-gzip' length 396704 bytes (387 KB) downloaded 387 KB The downloaded binary packages are in /var/folders/5h/8w5vp_nn2z1cq0jf13v38sfw0000gn/T//RtmpNxY0Nn/downloaded_packages Downloading GitHub repo NorskRegnesentral/shapr@HEAD ── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ checking for file ‘/private/var/folders/5h/8w5vp_nn2z1cq0jf13v38sfw0000gn/T/RtmpNxY0Nn/remotes6ef07a5dc888/NorskRegnesentral-shapr-111053f/DESCRIPTION’ ... ─ preparing ‘shapr’: ✔ checking DESCRIPTION meta-information ... ─ cleaning src ─ checking for LF line-endings in source and make files and shell scripts ─ checking for empty or unneeded directories Omitted ‘LazyData’ from DESCRIPTION ─ building ‘shapr_0.2.3.9100.tar.gz’ * installing *source* package ‘shapr’ ... ** using staged installation ** libs using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’ using SDK: ‘’ clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c AICc.cpp -o AICc.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c distance.cpp -o distance.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c features.cpp -o features.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c impute_data.cpp -o impute_data.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/RcppArmadillo/include' -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c weighted_matrix.cpp -o weighted_matrix.o clang++ -arch arm64 -std=gnu++17 -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 -o shapr.so AICc.o RcppExports.o distance.o features.o impute_data.o weighted_matrix.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0 -L/opt/gfortran/lib -lgfortran -lemutls_w -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation ld: warning: directory not found for option '-L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0' ld: warning: directory not found for option '-L/opt/gfortran/lib' ld: library not found for -lgfortran clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [shapr.so] Error 1 ERROR: compilation failed for package ‘shapr’ * removing ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/shapr’ * restoring previous ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/shapr’ Warning message: In i.p(...) : installation of package ‘/var/folders/5h/8w5vp_nn2z1cq0jf13v38sfw0000gn/T//RtmpNxY0Nn/file6ef064c6585e/shapr_0.2.3.9100.tar.gz’ had non-zero exit status
martinju commented 1 year ago

So, it seems you are missing the gfortran unix package. This is not specific to shapr, but apparently needed by the R-package RcppArmadillo which shapr uses.

Not a mac user myself, but it seems you are not the first one with such an error. See e.g. https://stackoverflow.com/questions/69639782/installing-gfortran-on-macbook-with-apple-m1-chip-for-use-in-r

I suggest you look at the solutions to the above SO question, and related ones you can find on the installation of gfortran on mac with m1 processor.

dtroxell19 commented 1 year ago

Great, this worked for me. I had forgotten to edit the ~/.R/Makevars file. Thanks for the help!