Installing OpenMP-enabled XGBoost

gcchomebrewpython

I have scoured the web trying to figure out how to install XGboost. A simple pip or conda install does not work, even though it worked for many of my colleagues. I went to the installation guide which directed me to run the following to install gcc:

brew install gcc --without-multilib

To confirm I already have it installed I tried again and received the following message:

Warning: gcc-7.1.0 already installed

So I should be good there.
Then I clone the repository with:

git clone --recursive https://github.com/dmlc/xgboost

and then run the following:

cd xgboost; cp make/config.mk ./config.mk; make -j4

and run in to the following errors:

c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/c_api/c_api.o src/c_api/c_api.cc >build/c_api/c_api.d
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d
clangclang: : errorerror: : unsupported option '-fopenmp'unsupported option '-fopenmp'

clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make: * [build/c_api/c_api_error.o] Error 1
make:
Waiting for unfinished jobs….
make:
[build/logging.o] Error 1
make: *
[build/learner.o] Error 1
make: *** [build/c_api/c_api.o] Error 1

I can't make sense of what the issue is, but really need XGboost to run through Python on my computer!

installation guide:
http://xgboost.readthedocs.io/en/latest/build.html

system version: macOS Sierra Version 10.12.4

Best Answer

I know this is old, but I had the exact same error as you and here is what I did to solve it. I edited the first few lines of the config.mk file yopu are copying to be

export CC = gcc-7
export CXX = g++-7

because you are using gcc 7.1

Then you can finish making and building as you can find in many tutorials (e.g. https://stackoverflow.com/questions/39315156/how-to-install-xgboost-in-python-on-macos)