简体   繁体   English

如何在Linux Cluster上使用Rmpi来增加DEoptim可用的内核?

[英]How to use Rmpi in R on linux Cluster to increase cores available with DEoptim?

I am using code developed in R to calibrate a hydrological model with 8 parameters using DEoptim (a function that aims to minimise an objective function). 我使用R开发的代码使用DEoptim(一种旨在最小化目标函数的函数)来校准具有8个参数的水文模型。 The DEoptim code uses the 'parallel' package to detect the number of cores available using 'DetectCores()'. DEoptim代码使用'parallel'包来检测可用的内核数量,使用'DetectCores()'。 On my PC I have 4 cores with 2 threads each so it detects 8 cores and then sends out the hydrological model to a core with different values of parameters and the results are returned to the centre. 在我的PC上,我有4个核心,每个核心有2个线程,因此它可以检测到8个核心,然后将水文模型发送到具有不同参数值的核心,并将结果返回到中心。 It does this hundreds or thousands of times and iterates the parameters to try and find an optimum set. 它完成了数百次或数千次并迭代参数以尝试找到最佳集合。 Therefore the more cores available, the faster it will work. 因此,可用的内核越多,它的工作速度就越快。

I am at a university and have access to a Linux compute cluster. 我在大学,可以访问Linux计算群集。 They have servers with up to 12 cores (ie not threads) and if I used this it would work two - three times faster than my PC. 他们有最多12个核心的服务器(即不是线程),如果我使用它,它将比我的PC快两到三倍。 Great. 大。 However, ideally I would spread the code around other servers so I could have access to more cores and all the info sent back the master. 但是,理想情况下,我会将代码分布在其他服务器上,这样我就可以访问更多内核,并将所有信息发送回主服务器。

Therefore, my question is how could I include Rmpi in my code to effectively increase the cores available. 因此,我的问题是如何在我的代码中包含Rmpi以有效地增加可用内核。 As you can probably tell, I am quite new to using clusters. 你可能会说,我对使用集群很新。

Many thanks, Antony 非常感谢,安东尼

If you want to execute DEoptim on multiple nodes of a Linux cluster, I believe you'll need to use foreach by specifying parallelType=2 in the control argument. 如果你想在Linux集群的多个节点上执行DEoptim ,我相信你需要通过在control参数中指定parallelType=2来使用foreach You can use either the doMPI parallel backend or the doParallel backend with an MPI cluster object. 您可以将doMPI并行后端或doParallel后端与MPI集群对象一起使用。 For example: 例如:

library(doParallel)
library(Rmpi)
cl <- makeCluster(mpi.universe.size()-1, type='MPI')
registerDoParallel(cl)

# and eventually...
DEoptim(fn=Genrose, lower=rep(-25, n), upper=rep(25, n),
  control=list(NP=10*n, itermax=maxIt, parallelType=2))

You'll need to have the snow package installed in addition to the others. 除了其他包装外,您还需要安装snow包。 Also, make sure that you execute your script with mpirun using the -np 1 option. 另外,请确保使用-np 1选项使用mpirun执行脚本。 If you don't use mpirun, the workers will all be spawned on the local machine. 如果你不使用mpirun,工作人员将全部在本地机器上生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM