Matlab Parallel Computing Toolbox 是否只为一个核心分配 1 个工作人员?

Does Matlab Parallel Computing Toolbox only assign 1 worker for one core?

您好,我正在使用 matlab 并行计算工具箱进行并行计算。我的笔记本电脑是 2 核 4 线程,所以我假设任务可以连接到 4 个工作?但是,当我输入命令 "matlabpool open" 时,只连接了 2 个工作人员。谁能告诉我如何指定要连接的工作人员的确切数量,以便我可以将任务分配给工作人员的数量多于核心的数量,从而使计算更有效?谢谢!

您可以告诉 matlab 使用特定数量的 worker,但它不会让您使用超过最大数量,这可能是 您的物理内核数量依赖于版本和集群。 R2012b 允许在本地集群中使用 12 个 worker,R2014a allows more than 12.

来自help matlabpool

...

matlabpool [poolSize]

...

matlabpool or matlabpool OPEN starts a worker pool using the default cluster profile with the pool size specified by that profile. You can also specify the pool size using matlabpool OPEN <poolSize>, but note that most clusters have a maximum number of processes that they can start.

% Start a worker pool using the local profile with 2 workers:
matlabpool local 2

更新:

我玩了一下。在 R2012b 上要求 16 名工人给我错误

You requested a minimum of 16 workers, but only 12 workers are allowed with the Local cluster.

这意味着这个版本不可能有更多的工人。但是,如果我用 12 个工作人员调用本地池,我会得到错误

You requested a minimum of 12 workers, but the cluster "local" has the NumWorkers property set to allow a maximum of 4 workers. To run a communicating job on more workers than this (up to a maximum of 12 for the Local cluster), increase the value of the NumWorkers property for the cluster. The default value of NumWorkers for a Local cluster is the number of cores on the local machine.

因此,您可能无法使用超过 12 个工作器,具体取决于您的版本。如果您看到 latter 错误,您可以重新定义集群以允许更多核心。复制 local 池:

mycluster=parcluster('local');
mycluster.NumWorkers=48;
matlabpool(mycluster,48);
...
matlabpool close;