由于共享库中的错误,自定义XGBoost的安装失败

问题描述 投票:0回答:1

我试图从R中的https://github.com/robjhyndman/M4metalearning设置自定义版本的XGBoost

当我运行devtools::install_github("pmontman/customxgboost")时,我收到此错误:

> devtools::install_github("pmontman/customxgboost")
Downloading GitHub repo pmontman/customxgboost@master
✔  checking for file ‘/private/var/folders/5g/1cypnkxn3fs6tbk5ylfp1rqm0000gn/T/RtmpwXcO18/remotes1ff65ae3da8c/pmontman-customxgboost-ac8dacf/DESCRIPTION’ ...
─  preparing ‘xgboost’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
✔  checking vignette meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘xgboost_666.6.4.1.tar.gz’
   Warning: file 'xgboost/cleanup' did not have execute permissions: corrected

* installing *source* package ‘xgboost’ ...
configure: creating ./config.status
config.status: creating src/Makevars
** libs
/usr/local/bin/gcc-8 -std=gnu++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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c xgboost_R.cc -o xgboost_R.o
/usr/local/bin/gcc-8 -std=gnu++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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c xgboost_custom.cc -o xgboost_custom.o
/usr/local/bin/gcc-8 -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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include   -fPIC  -Wall -g -O2  -c xgboost_assert.c -o xgboost_assert.o
/usr/local/bin/gcc-8 -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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include   -fPIC  -Wall -g -O2  -c init.c -o init.o
/usr/local/bin/gcc-8 -std=gnu++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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c amalgamation/xgboost-all0.cc -o amalgamation/xgboost-all0.o
/usr/local/bin/gcc-8 -std=gnu++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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c amalgamation/dmlc-minimum0.cc -o amalgamation/dmlc-minimum0.o
/usr/local/bin/gcc-8 -std=gnu++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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c rabit/src/engine_empty.cc -o rabit/src/engine_empty.o
/usr/local/bin/gcc-8 -std=gnu++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=0 -DDMLC_DISABLE_STDIN=1 -DDMLC_LOG_CUSTOMIZE=1 -DXGBOOST_CUSTOMIZE_LOGGER=1 -DRABIT_CUSTOMIZE_MSG_ -DRABIT_STRICT_CXX98_  -I/usr/local/include  -fopenmp  -fPIC  -Wall -g -O2 -c rabit/src/c_api.cc -o rabit/src/c_api.o
/usr/local/bin/gcc-8 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o xgboost.so ./xgboost_R.o ./xgboost_custom.o ./xgboost_assert.o ./init.o ./amalgamation/xgboost-all0.o ./amalgamation/dmlc-minimum0.o ./rabit/src/engine_empty.o ./rabit/src/c_api.o -fopenmp -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs
** R
** data
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘xgboost’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so, 6): Symbol not found: __ZNSt11regex_errorD1Ev
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost/libs/xgboost.so
Error: loading failed
Ejecución interrumpida
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xgboost’
Error in i.p(...) : 
  (convertido del aviso) installation of package ‘/var/folders/5g/1cypnkxn3fs6tbk5ylfp1rqm0000gn/T//RtmpwXcO18/file1ff67e4c38d5/xgboost_666.6.4.1.tar.gz’ had non-zero exit status

我正在使用

我的〜/ .R / Makevars文件如下:

CC=/usr/local/bin/gcc-8
CXX=/usr/local/bin/g++-8
CXX11=/usr/local/bin/gcc-8

我也尝试按照本指南安装原始的XGBoost:https://xgboost.readthedocs.io/en/latest/build.html

一切都很顺利。所以问题完全是R,我有点卡住了。有什么建议吗?

r gcc installation xgboost
1个回答
0
投票

最后我解决了这个问题,我将描述整个过程。

实质上,您必须遵循以下步骤:

https://xgboost.readthedocs.io/en/latest/build.html

具体来说,这很重要:brew install gcc@8

由于某些并行特性的性质,此命令将支持openMP的gcc版本下载到XGBoost的重要库。

也许共享库xgboost.so由于“未找到符号错误”而失败。当您尝试链接从不同gcc版本编译的对象时,会发生这种情况。

更多信息:What does "Symbol not found / Expected in: flat namespace" actually mean?

为了解决这个问题,我将~/.R/Makevars文件的内容更改为:

CC=/usr/local/bin/gcc-8 CXX=/usr/local/bin/g++-8 CXX11=/usr/local/bin/g++-8

注意CX11与原始问题版本不同。

这解决了我的问题。

有关更多信息Makevars file here:Understanding the contents of the Makevars file in R (macros, variables, ~/.R/Makevars and pkg/src/Makevars)

如果上述失败,建议删除将R库和重新安装它,则可能是一个符号链接或类似的问题。

R库(Mac Os High Sierra)存储在这里:

/Library/Frameworks/R.framework/Versions/3.5/Resources/library/

© www.soinside.com 2019 - 2024. All rights reserved.