本文介绍了rmpi:mclapply:在selectChildren(ac,1)中:在select中出现错误“系统调用中断"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下最小示例...

require(Rmpi)
set.seed(1)
foo <- parallel::mclapply(seq_len(10), function(l)
                          lapply(1:10, function(x) mean(rnorm(10000, mean=x))),
                          mc.cores=4)

...产生类型的警告消息

... produces warning messages of type

1: In selectChildren(ac, 1) : error 'Interrupted system call' in select
2: In selectChildren(ac, 1) : error 'Interrupted system call' in select
3: In selectChildren(ac, 1) : error 'Interrupted system call' in select

如何避免它们?

我在包装中使用Rmpiparallelmclapply,这就是我要问的原因.请注意,此信息已此处发布,但我尚未收到答案.如果这很重要,我将使用Ubuntu 12.10,Emacs 24和R 2.15.2

I use Rmpi and parallel's mclapply in a package, that's why I am asking. Note that this has been posted here but I haven't received an answer (yet). In case this matters, I work with Ubuntu 12.10, Emacs 24, and R 2.15.2

推荐答案

我在使用Open MPI 1.4.3构建的Rmpi安装中看到了此问题.我假设自从您使用Ubuntu以来,您也在使用Open MPI.加载Rmpi调用MPI_Init,这将导致捕获而不是忽略SIGCHLD信号.我相信结果是,当mclapply派生的子进程退出时,SIGCHLD现在将被发送,这会意外中断mclapply中的select系统调用.如果这不会导致任何实际错误,则可以通过在suppressWarnings中调用mclapply来防止出现警告消息.

I see this problem with my Rmpi installation which was built using Open MPI 1.4.3. I assume you're also using Open MPI since you use Ubuntu. Loading Rmpi calls MPI_Init which causes the SIGCHLD signal to be caught rather than ignored. I believe the result is that SIGCHLD will now be sent when child processes forked by mclapply exit, which unexpectedly interrupts select system calls in mclapply. If this doesn't cause any actual errors, you could prevent the warning messages by calling mclapply inside suppressWarnings.

对该问题的讨论在Open MPI用户的邮件列表中,这表明该问题已在Open MPI 1.6系列中得到了解决,因此,解决此问题的最佳方法可能是升级MPI安装(如果尚未安装的话).

There's a discussion of this issue in the Open MPI user's mailing list which suggests that the issue was fixed at some point in Open MPI 1.6 series, so the best solution to this problem may be to upgrade your MPI installation if you haven't already.

更新

我使用Open MPI 1.6.5和1.7.3尝试了您的示例,但是问题仍然存在.我决定使用inline包来实现将SIGCHLD信号重置为默认处理的功能.使用该代码,我可以在不产生任何警告的情况下运行您的示例:

I tried your example using Open MPI 1.6.5 and 1.7.3, but the problem persists. I decided to use the inline package to implement a function that resets the SIGCHLD signal to the default handling. Using that I was able run your example without generating any warnings:

library(Rmpi)
library(inline)
includes <- "#include <signal.h>"
code <- "signal(SIGCHLD, SIG_DFL);"
ignchld <- cfunction(body=code, includes=includes, convention=".C")
ignchld()
foo <- parallel::mclapply(seq_len(10), function(l)
                          lapply(1:10, function(x) mean(rnorm(10000, mean=x))),
                          mc.cores=4)

当然,禁用信号可能会导致Rmpi出现一些问题.在那种情况下,您可以修改代码以保存和恢复SIGCHLD处理程序,但是我不知道这是否有必要.

Of course, it's possible that disabling the signal will cause some problems for Rmpi. In that case, you could modify the code to save and restore the SIGCHLD handler, but I don't know if that is necessary.

这篇关于rmpi:mclapply:在selectChildren(ac,1)中:在select中出现错误“系统调用中断"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 11:58