问题
I am on Win7 OS with R 3.3.1 in Rstudio. Intention is to use glmnet
with parallel processing. From the ?glmnet
help:
parallel
: IfTRUE
, use parallel foreach to fit each fold. Must register parallel before hand, such asdoMC
or others. See the example below.
From the referenced example:
# Parallel
require(doMC)
registerDoMC(cores=4)
install.packages('doMC')
returns package is not available. Manually checking CRAN gives downloadable UNIX code but Windows binaries are not available.
Can I still use doMC
like code under my Win7 OS or what is a useful alternative?
回答1:
As written in the vignette to doMC
The doMC package acts as an interface between foreach and the multicore functionality of the parallel package, originally written by Simon Urbanek and incorporated into parallel for R2.14.0. The multicore functionality currently only works with operating systems that support the fork system call (which means that Windows isn't supported)
You can try to use the snow
package and a SOCK
cluster instead. (Thx @HongOoi for the hint that loading doSNOW
is not really required.)
library(doParallel)
#the following line will create a local 4-node snow cluster
workers=makeCluster(4,type="SOCK")
registerDoParallel(workers)
foreach(i=1:4) %dopar% Sys.getpid()
来源:https://stackoverflow.com/questions/40426115/how-to-use-domc-under-windows-or-alternative-parallel-processing-implementation