Is there a supported alternative to feature('numCores') to get the number of cores available for a parallel solution

15 次查看(过去 30 天)
I have an application that is compiled and distributed among a number of my office colleagues. Now we are trying to also set it up on a virtual machine to be accessed remotely by some other companies. During initialization the application is supposed to determine the number of cores available on the host machine using the undocumented command
avail_CPUs = feature('numCores');
The user can choose how many of the available cores they can use for the solution since the parfor will only run if they choose more than one.
When I tested the compiled on the virtual machine it gave me an error message. I can probably get around the problem by simply putting in a try - catch around this command. But it worries me to become dependent on undocumented commands. Is there an alternative? Also does a virtual machine by default only have one core?
  1 个评论
Raymond Norris
Raymond Norris 2022-8-15
What error message was thrown? What threw it, MATLAB? shell script?
When a user builds their virtual machine, they'll specify how many cores, RAM, etc it has.

请先登录,再进行评论。

回答(1 个)

Bruno Luong
Bruno Luong 2022-8-15
What about:
maxNumCompThreads()
ans = 2

类别

Help CenterFile Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by