mlampros / ClusterR

Gaussian mixture models, k-means, mini-batch-kmeans and k-medoids clustering
https://mlampros.github.io/ClusterR/
84 stars 29 forks source link

Unable to install on MacOs High Sierra, R: 3.4.3 #12

Closed vitasiku closed 5 years ago

vitasiku commented 5 years ago

I get "clang: error: unsupported option '-fopenmp'". MacOs: High Sierra R: 3.4.3

Similarly to this Originally posted by @vitasiku in https://github.com/mlampros/ClusterR/issues/3#issuecomment-444274724

mlampros commented 5 years ago

@vitasiku,

the issue that you refer had actually to do with an installation problem of the 'gmp' package, on which the ClusterR package depends. It was a temporary issue which is now fixed. As you can also see in the package check results the ClusterR package can be installed on Macintosh (currently it's tested on OS X 10.11.6 which is the El Capitan version and CRAN uses Xcode 8.2.1, clang 4.0.0, GNU Fortran 6.1).

I use Macintosh Sierra too but it is configured with gcc support (I used brew to upgrade gcc). An extensive tutorial on how to make OpenMP and Rcpp work on Macintosh can be found here. Not only ClusterR but also the RcppArmadillo (on which ClusterR depends) uses internally OpenMP to improve efficiency.

I run the following examples (threads = 1 and threads = 2) on my Macintosh Sierra with the current version of ClusterR (1.1.6) and it worked error free,

#----------------
# threads = 1
#----------------

library(ClusterR)
data(dietary_survey_IBS)
dat = dietary_survey_IBS[, -ncol(dietary_survey_IBS)]
dat = distance_matrix(dat, method = 'euclidean', upper = TRUE, diagonal = TRUE, threads = 1)

#----------------
# threads = 2
#----------------

dat1 = distance_matrix(dat, method = 'euclidean', upper = TRUE, diagonal = TRUE, threads = 2)

So, the reason that you get the openmp error is because Macintosh does not natively support OpenMP.

vitasiku commented 5 years ago

@mlampros thanks for the extensive reply. I will try and follow the tutorial in the link.

stale[bot] commented 5 years ago

This is Robo-lampros because the Human-lampros is lazy. This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs. Feel free to re-open a closed issue and the Human-lampros will respond.