加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 02:52:41 所属栏目:Windows 来源:网络整理
导读:我在Rstudio中使用R 3.3.1的Win7 OS.意图是使用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. 从引用的例子: # Paral
我在Rstudio中使用R 3.3.1的Win7 OS.意图是使用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’)返回包不可用.手动检查CRAN提供可下载的UNIX代码,但Windows二进制文件不可用.

我仍然可以在Win7操作系统下使用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()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读