r - 如何通过 bsub 提交 doMPI 作业?
问题描述
我正在尝试使用带有 doMPI 包的 foreach 循环提交 R 脚本。不幸的是,该过程在 50 个请求的节点中的每一个上启动。但我希望每个节点都用于执行其中一次 foreach 迭代。
这就是我提交 R 脚本的方式。
bsub -n 50 -J "test doMPI 50" 'mpirun -n 1 R --slave -f sincMPI.R'
的内容sincMPI.R
是
suppressMessages(library(doMPI))
# Create and register an MPI cluster
cl <- startMPIcluster()
registerDoMPI(cl)
x <- 1:200
out_path = "out_dt.csv"
foreach(y=x, .combine="cbind") %dopar% {
library(data.table, quietly = T)
library(flock, quietly = T)
dt_out <- data.table(
times1 = x*1,
times2 = x*2,
times3 = x*3
)
lock <- flock::lock(out_path)
fwrite(dt_out, out_path, append = TRUE)
flock::unlock(lock)
}
# Shutdown the cluster and quit
closeCluster(cl)
mpi.quit()
这改编自 doMPI 包中的示例。
结果 in"out_dt.csv"
现在的行数比预期的多 50 倍,因为每个节点都在执行所有 foreach 迭代。
为什么会发生这种情况?如何将 50 个内核中的 49 个用作从属进程,而不是全部作为主进程?
解决方案
推荐阅读
- java - 模块目录或模块文件内部名称应相同或不同
- javascript - SortableJS `revertClone` 选项如何工作?
- php - 当我有超过 1 个选项卡时提交按钮问题?
- linux - 我如何 ngrok 编辑转发 tcp url 名称以及如何设置其他名称使用参数变量?
- flutter - 需要帮助从自定义小部件中获取相应的价值
- soapui - Soap-UI 5.4.0 模拟服务
- git - 带有自动合并策略的 git pull --rebase 不起作用
- java - 无法添加 Telegram 机器人库;初学者失败?
- android - 如何使具有 numberDecimal 输入类型的 EditText 将小数分隔符显示为“,”而不是“。” 根据应用程序区域设置?
- java - 是否可以使用可以在 java 中初始化变量的双输入创建异常处理方法?