问题描述
我在R中使用xgb.cv和xgboost.但是,它不能并行运行
I am using xgb.cv and xgboost in R. However, it is not working as parallel
我的示例代码如下
library(xgboost)
library(parallel)
param <- list("objective" = "reg:logistic"
, "eval_metric" = "logloss"
,"nthread" = 8
,"bst:eta" = .025
,"bst:max_depth" = 3
,"lambda" = 1
,"lambda_bias" = 0
,"alpha" = .8
,"min_child_weight" = 3
,"subsample" = .9
,"colsample_bytree" = .6)
bst.cv3 = xgb.cv(param=param, data = x, label = y,
nfold = 3, nrounds=cv.nround, missing = NA
,prediction = TRUE)
但是,以上代码无法正常工作.我该怎么做才能使其平行?
However, above code is not working. What I have to do to make them parallel?
我在xgboost网站和github上发现了这个东西
There is thing I found this on xgboost website and github
https://github.com/dmlc/xgboost/issues/276
但是,我不能跑步
brew install clang-omp
或
brew install gcc --without-multilib
带有sudo的
也不起作用谢谢
with sudo also not workingThanks
推荐答案
不幸的是,以前选择的答案现在已过时. clang-omp
软件包在自制软件中不再可用.所以这是对我有用的.
The previously selected answer unfortunately is now outdated. The clang-omp
package is no longer available in homebrew. So here's what worked for me.
首先,在外壳上:
brew reinstall gcc --without-multilib
然后,创建具有以下内容的文件~/.R/Makevars
,确保更新路径,以便它们正确反映已安装的gcc版本自制软件:
Then, create the file ~/.R/Makevars
with the following contents, making sure to update the paths so they correctly reflect the gcc version homebrew installed:
CC=/usr/local/Cellar/gcc/6.1.0/bin/gcc-6
CXX=/usr/local/Cellar/gcc/6.1.0/bin/g++-6
SHLIB_CXXLD=/usr/local/Cellar/gcc/6.1.0/bin/g++-6
FC=/usr/local/Cellar/gcc/6.1.0/bin/gfortran-6
F77=/usr/local/Cellar/gcc/6.1.0/bin/gfortran-6
MAKE=make -j8
SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp
最后,重新启动R或RStudio,然后从源代码重新安装软件包.
Finally, restart R or RStudio and re-install the packages from source.
在上写了一篇关于此的小型博客文章顺便说一下,https://asieira.github.io/using-openmp-with-r-packages-in-os-x.html .
这篇关于如何使用OpenMP编译在OS X中并行处理R包xgboost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!