我是writing an R package,具有并行代码
anpl <- function(..., num_cores = 1, ...)
...
theta_transpose <- parallel::mcmapply(anpl_single, 1:n_bootstrap,
MoreArgs = more_args, mc.cores = num_cores)
...
其中anpl
代表自适应非参数学习。
我测试tests/testthat/test_anpl.R
中的代码:
test_that("Adaptive non-parametric learning with posterior samples works", {
...
anpl_samples <- anpl(..., num_cores = 2)
...
}
呼叫devtools::check()
可以正常工作:
── R CMD check results ─────────────────────────── PosteriorBootstrap 0.0.1 ────
Duration: 1m 15.1s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
调用devtools::test()
会显示并行化错误:
══ Results ═════════════════════════════════════════════════════════════════════
Duration: 59.5 s
OK: 21
Failed: 0
Warnings: 0
Skipped: 0
Error while shutting down parallel: unable to terminate some child processes
我发现与Slurm有关的this issue仍处于打开状态,而与processx
有关的this issue与其中的解决方法使用调用parallel
和processx
的顺序有关不适用于这里。
有什么问题,我该如何解决?