[R] Fwd: Huge memory utilization when using doMC library
Srikanth Gumma
sri4mailing at gmail.com
Mon Feb 16 06:03:45 CET 2015
Hi,
I'm the administrator of HPC cluster and one of the user reported that their
R job is vary slow. Below is the code that the user provided to me. May I
request your suggestion why the code is so slow and utilizing 100% memory?
I have installed R version 3.1.2 and RJags_3-14.
## data ##
set.seed(2015)
N <- 1000
y.i <- rnorm(N, 10, 0.1)
## set up MCMC ##
mcmc.chains <- 3
ChainIDs <- seq(1, mcmc.chains)
mcmc.burnin <- 2
N.STEPS <- 2
n.iter.perstep <- 3
mcmc.thin <- 1
mort.parameters <- c("mu")
mort.data <- list(y.i = y.i, N = N)
jagsStep.dir <- paste0("JAGSoutput/")
dir.create("JAGSoutput/", showWarnings = FALSE)
library(foreach)
library(R2jags)
library(doMC) ## for linux server only
registerDoMC(4)
## start MCMC
foreach(chain = ChainIDs) %dopar% {
chain*chain
set.seed(2013 + chain * 1000)
rnorm(chain)
mod <- jags(data = mort.data, #inits = mort.inits,
parameters.to.save = mort.parameters,
model.file = "test.txt",
jags.seed = chain,
n.chains = 1, n.iter = n.iter.perstep + mcmc.burnin,
n.burnin = mcmc.burnin, n.thin = mcmc.thin, DIC = TRUE)
}#end of chain loop
## the end ##
Thanks in advance.
Regards
Srikanth.
[[alternative HTML version deleted]]
More information about the R-help
mailing list