我使用使用包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