dmlc / xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://xgboost.readthedocs.io/en/stable/
Apache License 2.0
26.28k stars 8.73k forks source link

OSX installation trouble on 10.12.1 #1835

Closed ben519 closed 7 years ago

ben519 commented 7 years ago

I'm trying to install xgboost with multi-threading for R. I had this working on OSX 10.11 but I recently upgraded to 10.12.1 and now I'm running into some trouble. Note that I'm following the instructions in building-on-osx.

First I ran brew install homebrew/versions/gcc6

benjamins-MacBook-Pro-3:~ Ben$ brew install homebrew/versions/gcc6
==> Tapping homebrew/versions
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-versions'...
remote: Counting objects: 218, done.
remote: Compressing objects: 100% (212/212), done.
remote: Total 218 (delta 21), reused 42 (delta 5), pack-reused 0
Receiving objects: 100% (218/218), 259.40 KiB | 0 bytes/s, done.
Resolving deltas: 100% (21/21), done.
Checking connectivity... done.
Tapped 209 formulae (238 files, 960.8K)
==> Installing gcc6 from homebrew/versions
==> Installing dependencies for homebrew/versions/gcc6: gmp, mpfr, isl014
==> Installing homebrew/versions/gcc6 dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.1.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gmp-6.1.1.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/gmp/6.1.1: 17 files, 3.2M
==> Installing homebrew/versions/gcc6 dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-3.1.5.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mpfr-3.1.5.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/mpfr/3.1.5: 25 files, 3.6M
==> Installing homebrew/versions/gcc6 dependency: isl014
==> Downloading http://isl.gforge.inria.fr/isl-0.14.tar.bz2
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/isl014/0.14 --with-gmp=system --with-gmp-prefix=/usr/local/opt/gmp
==> make
==> make install
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

Conflicts with isl in main repository.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/isl014/lib
    CPPFLAGS: -I/usr/local/opt/isl014/include
    PKG_CONFIG_PATH: /usr/local/opt/isl014/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/isl014/0.14: 70 files, 3.2M, built in 30 seconds
==> Installing homebrew/versions/gcc6
==> Downloading https://homebrew.bintray.com/bottles-versions/gcc6-6.2.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gcc6-6.2.0.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/gcc6/6.2.0: 1,434 files, 274.7M

No errors, but note the Caveat. Now if I try

benjamins-MacBook-Pro-3:~ Ben$ which clang-omp++
benjamins-MacBook-Pro-3:~ Ben$ 

I get nothing. I read in another issue-thread that this means the installation was unsuccessful (see here). Also note the following

benjamins-MacBook-Pro-3:~ Ben$ which clang
/usr/bin/clang
benjamins-MacBook-Pro-3:~ Ben$ which clang++
/usr/bin/clang++
benjamins-MacBook-Pro-3:~ Ben$ 

Not sure if this is relevant, but I use R's data.table package which enables multi-threading so I've already (successfully) followed their openmp-enabled-compiler-for-mac instructions. Could it be causing a conflict?

chvlyl commented 7 years ago

I recently tried to install XGBoost on my macbook and also ran into some problems. I did some search and found that the key issue is the to find the right complier for XGBoost for Mac OSX. For your problem, my understanding is that gcc and clang are two different compliers. clang from XCode does not support OpenMP. So I tried to install clang-omp.

In my case, I installed clang-omp by brew install clang-omp It works for me.

Hope this helps.

ben519 commented 7 years ago

I think I got it, although I'm not sure how. One last thing though - after I build the package, how do I install it? I'm looking for a ".tar.gz" file for which I can do install.packages(path_to_file, repos = NULL, type="source"). Is this incorrect? Or, where is the .tar file for me to install?

ben519 commented 7 years ago

Running into yet another problem :(

library(devtools)
devtools::install('/Users/Ben/xgboost/R-package')

output

Installing xgboost
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL '/Users/Ben/xgboost/R-package'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library' --install-tests 

* installing *source* package ‘xgboost’ ...
** libs
g++-5 -std=c++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I../..//include -I../..//dmlc-core/include -I../..//rabit/include -I../../ -DXGBOOST_STRICT_R_MODE=1 -DDMLC_LOG_BEFORE_THROW=0 -DDMLC_ENABLE_STD_THREAD=1 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_ -I/usr/local/opt/llvm/include   -fopenmp  -fPIC  -Wall -mtune=core2 -g -O2 -c xgboost_R.cc -o xgboost_R.o
In file included from ../..//dmlc-core/include/dmlc/logging.h:10:0,
                 from xgboost_R.cc:2:
/usr/local/Cellar/gcc/5.3.0/include/c++/5.3.0/cstdio:42:19: fatal error: stdio.h: No such file or directory
compilation terminated.
make: *** [xgboost_R.o] Error 1
ERROR: compilation failed for package ‘xgboost’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/xgboost’
Error: Command failed (1)

I'll probably give up for now - the time I'll spend on this might not be worth the time saved by using multi-threading. Would love to revisit and get it working. Any help would be greatly appreciated!

ben519 commented 7 years ago

I worked through the installation process again. Still unsuccessful, but I documented my steps very clearly in this StackOverflow question. Hoping this will help someone easily spot my error.

ben519 commented 7 years ago

Solved it!