How to make xgboost R-package parallel in OS X using OpenMP compilation?

I use xgb.cv and xgboost in R. However, it does not work as parallel

My sample code following

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, the above code does not work. What should I do to make them parallel?

I found this on xgboost and github website

However i cant run

brew install clang-omp

or

brew install gcc --without-multilib

also does not work with sudo Thank you

+1
source share
3 answers

The previously selected answer, unfortunately, is now out of date. The package is clang-ompno longer available at homebrew. So this is what worked for me.

First in the shell:

brew reinstall gcc --without-multilib

~/.R/Makevars , , , gcc homebrew:

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 .

https://asieira.imtqy.com/using-openmp-with-r-packages-in-os-x.html, .

+4

, .

vi ~/.R/Makevars

CC=clang-omp
CXX=clang-omp++
CXX1X=clang-omp++
SHLIB_OPENMP_CFLAGS=-fopenmp
SHLIB_OPENMP_CXXFLAGS=-fopenmp
SHLIB_OPENMP_FCFLAGS=-fopenmp
SHLIB_OPENMP_FFLAGS=-fopenmp

install.packages("xgboost", repos="http://dmlc.ml/drat/", type = "source")

brew clang gcc

brew reinstall clang-omp

.

+3

Source: https://habr.com/ru/post/1662703/


All Articles