如何在Windows下使用doMC或glmnet的其他并行处理实现? [英] How to use doMC under Windows or alternative parallel processing implementation for glmnet?

查看:197
本文介绍了如何在Windows下使用doMC或glmnet的其他并行处理实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rstudio的R 3.3.1版本的Win7操作系统上。意图是在并行处理中使用 glmnet 。从?glmnet help:


parallel :如果 TRUE ,使用并行foreach来适应每个折叠。必须先手动并行注册
,如 doMC 或其他。请参阅下面的
示例。

从引用的例子:

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

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

我仍然可以在我的Win7操作系统下使用 doMC 类似的代码,或者是一个有用的选择吗?

解决方案

doMC


doMC包作为foreach和并行包的
多核功能之间的接口,最初由
Simon Urbanek编写,并入R2.14.0。
多核功能目前仅适用于支持fork系统调用的操作系统
(这意味着Windows不支持

您可以尝试使用 snow 包和一个 SOCK 群代替。 (Thx @HongOoi提示加载 doSNOW 并不是真的需要。)

  library(doParallel)

#下面一行将创建一个本地的4节点雪群
workers = makeCluster(4,type =SOCK)
registerDoParallel工作人员)

foreach(i = 1:4)%dopar%Sys.getpid()


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: If TRUE, use parallel foreach to fit each fold. Must register parallel before hand, such as doMC 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?

解决方案

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

这篇关于如何在Windows下使用doMC或glmnet的其他并行处理实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆