我使用使用包multicore
的doMC
。它发生了(几次),当我在调试时(在控制台中)它横向移动并且fork-bombed。有没有办法限制运行的R进程的数量
R是否有setrlimit()系统调用? 在pyhton为了这个,我会用resource.RLIMIT_NPROC
理想我想限制运行到数R进程的数量
编辑:操作系统是Linux CentOS 6的
我使用使用包multicore
的doMC
。它发生了(几次),当我在调试时(在控制台中)它横向移动并且fork-bombed。有没有办法限制运行的R进程的数量
R是否有setrlimit()系统调用? 在pyhton为了这个,我会用resource.RLIMIT_NPROC
理想我想限制运行到数R进程的数量
编辑:操作系统是Linux CentOS 6的
应该有几个选择。下面是从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' 线程的数目(又名 'GotoBLAS', 'ACML' 和 'MKL')。并可能控制'OpenMP'中的线程数量。如果可行的话,获得 许多逻辑核心和物理核心。
毕竟您需要控制并行会话的数量以及分配给每个并行线程的BLAS核心的数量。有一个原因,并行程序包的默认值为每个会话2个线程...
所有这些应该基本上独立于您正在运行的Linux或Unix的风格。那么,除了OS X当然(仍然!!)不给你OpenMP的事实。
而且你可以从doMC
和朋友那里控制的非常外层。
看起来很有前途,谢谢我会深入研究它 – statquant
你在使用什么操作系统?如果使用'doMC',我假设Linux。 – cdeterman