X中并行处理R包xgboost

X中并行处理R包xgboost

本文介绍了如何使用OpenMP编译在OS X中并行处理R包xgboost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在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

  1. https://github .com/dmlc/xgboost/blob/master/doc/build.md#building-on-osx

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:40