gpt4 book ai didi

MATLAB:控制核心/线程数

转载 作者:太空宇宙 更新时间:2023-11-03 20:08:03 27 4
gpt4 key购买 nike

假设我有一个程序要在具有 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 session )。运行 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);

最佳答案

不,这不是正确的监控工具。请查看 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有关功能的更多信息。

关于MATLAB:控制核心/线程数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39834042/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com