2

I am trying to install OpenMP enabled xgboost on my mac. I installed gcc with no problem:

brew install gcc --without-multilib

then cloned git repository:

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk

but I get an error when I do

make -j4

Here is the error I get. I'd appreciate if you can help fixing this problem:

c++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude   -Idmlc-core/include -Irabit/include -fPIC -fopenmp -o xgboost  build/cli_main.o build/learner.o build/logging.o build/c_api/c_api.o build/c_api/c_api_error.o build/common/common.o build/data/data.o build/data/simple_csr_source.o build/data/simple_dmatrix.o build/data/sparse_page_dmatrix.o build/data/sparse_page_raw_format.o build/data/sparse_page_source.o build/data/sparse_page_writer.o build/gbm/gblinear.o build/gbm/gbm.o build/gbm/gbtree.o build/metric/elementwise_metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit.a  -pthread -lm  -fopenmp 
c++ -std=c++0x -Wall -O3 -msse2  -Wno-unknown-pragmas -funroll-loops -Iinclude   -Idmlc-core/include -Irabit/include -fPIC -fopenmp -shared -o lib/libxgboost.so build/learner.o build/logging.o build/c_api/c_api.o build/c_api/c_api_error.o build/common/common.o build/data/data.o build/data/simple_csr_source.o build/data/simple_dmatrix.o build/data/sparse_page_dmatrix.o build/data/sparse_page_raw_format.o build/data/sparse_page_source.o build/data/sparse_page_writer.o build/gbm/gblinear.o build/gbm/gbm.o build/gbm/gbtree.o build/metric/elementwise_metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit.a -pthread -lm  -fopenmp 
clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'

ld: library not found for -lgomp
ld: library not found for -lgomp
clang: error: clanglinker command failed with exit code 1 (use -v to see invocation): 
error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libxgboost.so] Error 1
make: *** Waiting for unfinished jobs....
make: *** [xgboost] Error 1
4

2 回答 2

1

我有同样的问题并通过以下方式解决:

brew install clang-omp
export CC=clang-omp
export CXX=clang-omp++
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk; make -j4
cd python-package
sudo python setup.py install

如果您之前使用 pip 安装过 xgboost,则从您的项目中删除之前安装的 xgboost。然后使用

pip install xgboost 

重新安装它。

于 2016-03-25T09:41:06.073 回答
1

新版本的 OSX 有一个 Clang 作为默认的 c\c++ 编译器。因此,您的c++命令指的是clang++.

您应该像这样为您的 make 命令定义一个 CC\CXX 环境变量CC=gcc CXX=g++ make -j

您还可以为 clang OpenMPrt构建一个 OpenMP并自定义您的 shell 环境(我没有自己尝试过)

(我现在没有mac来检查这个解决方案;只有linux)

于 2016-03-19T22:15:19.517 回答