0

と を使用してクラスター コンピューターでモンテカルロ シミュレーションを実行していましsnowRRのラインに達するまで、すべてがうまくいきstopClusterRそこでフリーズし、最終的に壁の時間を超えました。の問題がわかりませんstopCluster

以下は、簡略化されたバージョンの私のRスクリプトです。

simu <- function(rep_worker, n_used) {
  theta_simu <- c()
  for (i in 1 : rep_worker) {
    theta_simu[i] <- mean(rnorm(n_used))
  }
  theta_simu
}
library(Rmpi)
library(snow)
np <- mpi.universe.size() - 1
cl <- makeCluster(np, type = "MPI")
## go go go
n_used <- 1e4
rep_worker_list <- rep(1, np) # each worker do one `simu`
theta_cluster <- clusterApply(cl, rep_worker_list, simu, n_used)
theta_cluster
stopCluster(cl)
mpi.exit()

上記のスクリプトはtest_stack.R、ディレクトリの下に保存されましたmonte-carlo/R。サーバーに送信したpbsスクリプトは次のとおりです。

#!/bin/bash

#PBS -N test
#PBS -l walltime=00:30:00
#PBS -l nodes=3:ppn=8
#PBS -l pvmem=8gb

module load R/3.3.1
module load openmpi/gcc/2.0.0
cd monte-carlo/R

# For snow jobs, use 'mpiexec -n 1'
mpiexec -n 1 R CMD BATCH test_stack.R

ファイルの一部をRout以下にリストしました。で止まりstopCluster()ます。

> simu <- function(rep_worker, n_used) {
+   theta_simu <- c()
+   for (i in 1 : rep_worker) {
+     theta_simu[i] <- mean(rnorm(n_used))
+   }
+   theta_simu
+ }
> library(Rmpi)
> library(snow)
> np <- mpi.universe.size() - 1
> cl <- makeCluster(np, type = "MPI")
    23 slaves are spawned successfully. 0 failed.
> ## go go go
> n_used <- 1e4
> rep_worker_list <- rep(1, np) # each worker do one `simu`
> theta_cluster <- clusterApply(cl, rep_worker_list, simu, n_used)
> theta_cluster
[[1]]
[1] 5.54539e-05

[[2]]
[1] 0.0009270881

... (I deleted the rest to save space)

> stopCluster(cl)
4

1 に答える 1