如何在 Windows 下使用 doMC 或 glmnet 的替代并行处理实现?

How to use doMC under Windows or alternative parallel processing implementation for glmnet?

我在 Win7 OS 上使用 Rstudio 中的 R 3.3.1。目的是使用 glmnet 进行并行处理。来自 ?glmnet 帮助:

parallel: If TRUE, use parallel foreach to fit each fold. Must register parallel before hand, such as doMC or others. See the example below.

来自参考示例:

# Parallel
require(doMC)
registerDoMC(cores=4)

install.packages('doMC') returns 包不可用。手动检查 CRAN 提供可下载的 UNIX 代码,但 Windows 二进制文件不可用。

我还能在我的 Win7 OS 下使用 doMC 之类的代码吗?或者有什么有用的替代方法?

正如 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)

您可以尝试使用 snow 包和 SOCK 集群。 (感谢@HongOoi 提示加载 doSNOW 并不是真正需要的。)

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()