我使用的是使用包doMC
的{{1}}。它发生了(好几次),当我在调试时(在控制台中)它横向移动并且fork-bombed。
R是否有setrlimit()系统调用? 在pyhton中,我会使用resource.RLIMIT_NPROC
理想情况下,我想将运行的R进程数量限制为数字
编辑:操作系统是linux CentOS 6答案 0 :(得分:3)
应该有几种选择。以下是Writing R Extensions, Section 1.2.1.1
的相关部分 Packages are not standard-alone programs, and an R process could
contain more than one OpenMP-enabled package as well as other components
(for example, an optimized BLAS) making use of OpenMP. So careful
consideration needs to be given to resource usage. OpenMP works with
parallel regions, and for most implementations the default is to use as
many threads as 'CPUs' for such regions. Parallel regions can be
nested, although it is common to use only a single thread below the
first level. The correctness of the detected number of 'CPUs' and the
assumption that the R process is entitled to use them all are both
dubious assumptions. The best way to limit resources is to limit the
overall number of threads available to OpenMP in the R process: this can
be done via environment variable 'OMP_THREAD_LIMIT', where
implemented.(4) Alternatively, the number of threads per region can be
limited by the environment variable 'OMP_NUM_THREADS' or API call
'omp_set_num_threads', or, better, for the regions in your code as part
of their specification. E.g. R uses
#pragma omp parallel for num_threads(nthreads) ...
That way you only control your own code and not that of other OpenMP
users.
我最喜欢的工具之一是控制它的包:RhpcBLASctl。这是它的描述:
控制' BLAS'上的线程数量。 (Aka' GotoBLAS',' ACML'和 ' MKL&#39)。并且可以控制' OpenMP'中的线程数量。得到 如果可行,可以使用许多逻辑核心和物理核心。
毕竟,您需要控制并行会话的数量以及分配给每个并行线程的BLAS核心的数量。有一个原因,并行包每个会话默认有2个线程......
所有这一切都应该在很大程度上独立于您运行的Linux或Unix的风格。好吧,除了OS X当然(仍然!!)没有给你OpenMP。
你可以从doMC
和朋友那里控制你的外层。
答案 1 :(得分:2)