- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在串行执行随机森林时,它在我的系统上使用 8GB 的 RAM,而在并行执行时,它使用超过两倍的 RAM (18GB)。并行执行时如何将其保持在 8GB?代码如下:
install.packages('foreach')
install.packages('doSMP')
install.packages('randomForest')
library('foreach')
library('doSMP')
library('randomForest')
NbrOfCores <- 8
workers <- startWorkers(NbrOfCores) # number of cores
registerDoSMP(workers)
getDoParName() # check name of parallel backend
getDoParVersion() # check version of parallel backend
getDoParWorkers() # check number of workers
#creating data and setting options for random forests
#if your run this please adapt it so it won't crash your system! This amount of data uses up to 18GB of RAM.
x <- matrix(runif(500000), 100000)
y <- gl(2, 50000)
#options
set.seed(1)
ntree=1000
ntree2 <- ntree/NbrOfCores
gc()
#running serialized version of random forests
system.time(
rf1 <- randomForest(x, y, ntree = ntree))
gc()
#running parallel version of random forests
system.time(
rf2 <- foreach(ntree = rep(ntree2, 8), .combine = combine, .packages = "randomForest") %dopar% randomForest(x, y, ntree = ntree))
最佳答案
首先,SMP 将复制输入,以便每个进程都有自己的副本。这可以通过使用 multicore
进行转义,但还有另一个问题 - randomForest
的每次调用也会生成输入的内部副本。
您可以通过使 randomForest
删除森林模型本身(使用 keep.forest=FALSE
)并在训练的同时进行测试(通过使用 xtest
和可能的 ytest
参数)。
关于r - 带有 doSMP 和 foreach 的并行随机森林大大增加了内存使用量(在 Windows 上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8776816/
我正在尝试使用 doSMP 包在 R 中进行并行编程。这是我编写的代码片段,用于测试每个 MC 复制是否从相同的种子开始,以及 RNG 是否会给出相同的数字 随机数出来的都是一样的。我希望每个 MC
有没有办法初始化一个类似于 clusterEvalQ 的 doSMP 集群和 clusterExport在雪包里?例如: x <- 1:10 y <- 10:1 z <- rnorm(10) cl <
此代码有效: library(plyr) x Error in do.ply(i) : task 3 failed - "subscript out of bounds" In addition: W
我正在尝试使用 doSMP/foreach 来并行化 R 中的一些代码。 我有一个巨大的二维遗传数据矩阵 - 10,000 个观察值(行)和 300 万个变量(列)。由于内存问题,我不得不将这些数据分
在串行执行随机森林时,它在我的系统上使用 8GB 的 RAM,而在并行执行时,它使用超过两倍的 RAM (18GB)。并行执行时如何将其保持在 8GB?代码如下: install.packages
我已经在 Windows 7 上安装了 R(64 位)版本 2.11.1,并且还从“REvolution foreach windows bundle”中打包了 doSMP 和 revoIPC 以进行
我已经在不同的机器上运行了一些测试代码,总是得到相同的结果。我认为各种 do... 包背后的理念是它们可以互换用作 foreach 的 %dopar% 的后端。为什么情况并非如此? 例如,此代码片段有
我是一名优秀的程序员,十分优秀!