【问题标题】:MATLAB: controlling for number core / threadsMATLAB:控制数量核心/线程
【发布时间】:2017-05-05 00:26:25
【问题描述】:

假设我有一个程序要在具有 32 个内核(64 个线程)的 linux 机器上运行,其中我只能使用 10 个内核(20 个线程)。所以我想在运行程序之前指定它。

我在谷歌上搜索并找到了maxNumCompThreads,但当我在一台装有 MATLAB 2016a、i5 核心(2 核心、4 线程)的机器上测试它时,它似乎不起作用。也就是说,当我执行以下任何操作时,feature('numCores') 会得到相同的输出

maxNumCompThreads(1)
maxNumCompThreads(2)
maxNumCompThreads(4)
maxNumCompThreads('Automatic')

然后我尝试了parpool(每次我用delete(gcp('nocreate')) 关闭当前的parpool 会话)。运行parpool(4) 时出现错误(我想我明白为什么:parpool 接受内核数量并自动启用超线程,并且测试机只有 2 个物理内核)。所以我用parpool(1)parpool(2) 进行了测试。同样,feature('numCores') 的输出没有没有改变。

问题:那么对于上面第一段中描述的情况,什么是适合这项工作的工具? feature('numCores') 是否是正确的监控工具来查看适当的规范是否生效?


我在上面一直提到的相同的feature('numCores') 输出是:

MATLAB detected: 2 physical cores.
MATLAB detected: 4 logical cores.
MATLAB was assigned: 4 logical cores by the OS.
MATLAB is using: 2 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.

编辑:当我在 linux 机器上运行 parpool(10) 时出现以下错误

Starting parallel pool (parpool) using the 'local' profile ... Error using parpo              ol (line 103)
Couldn't interpret output from psname.sh: ""

Error in parpool_test_2016_10_03 (line 3)
parpool(10);

【问题讨论】:

  • 您可能会在具有 2 个内核和 4 个线程的计算机中得到奇怪的结果,因为您不能使用更多/更少/parpool(1) 没有什么意义,如果它只有 1 个内核,它就不是并行池.不知道呃,只是假设
  • @AnderBiguri 很有趣。我会看看我是否能找到一种方法来测试它。会回来报告的。
  • @AnderBiguri 请查看编辑。 parpool 甚至不能在 linux 机器上工作。
  • 很奇怪,它应该可以在 Linux 上运行。另外,我认为您需要能够为每个核心提供 iicense,但无法确认。

标签: matlab parallel-processing


【解决方案1】:

不,它不是正确的监控工具。改为查看feature('numthreads')

>> feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.

ans =    
     4

>> feature('numthreads')    
ans =    
     4

>> maxNumCompThreads(1)    
ans =    
     4

>> feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.

ans =    
     4

>> feature('numthreads')    
ans =    
     1

一般来说,使用feature 时要小心,因为它没有记录在案并且容易在没有警告的情况下更改。请查看this postthis StackOverflow question,了解有关feature 的更多信息。

【讨论】:

    猜你喜欢
    • 2020-02-18
    • 2012-06-26
    • 1970-01-01
    • 2013-01-17
    • 2013-03-02
    • 2011-02-07
    • 2018-06-02
    • 2013-01-06
    相关资源
    最近更新 更多