目录
在matlab中默认是只能使用12个cores,然而有时候我们的Linux服务器cpu核心数可能远远大于12,
>> feature('numCores')
MATLAB detected: 72 physical cores.
MATLAB detected: 72 logical cores.
MATLAB was assigned: 72 logical cores by the OS.
MATLAB is using: 72 logical cores.
默认使用parfor的话,只能开启12 logical cores,
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 12).
而如果应选择72个cores的话,就会报错,
Error using parpool (line 149)
Found an interactive session. You cannot have multiple interactive sessions open simultaneously. To terminate the existing session, use delete(gcp('nocreate')).
Error in retrieve_bio_subs (line 24)
parpool(72); %开启并行计算
解决办法是采用maxNumCompThreads(72)
,设置最大可用的核心数。
Bug1:delete(gcp(‘nocreate’))
这里有个比较奇怪的bugError Found an interactive session. You cannot have multiple interactive sessions open simultaneously. To terminate the existing session, use 'delete(gcp('nocreate'))'
这个错误是因为我在之前开启了一个parpool但是没有关闭,与此同时,我又开启了一个新的parpool,所以导致冲突。
因此,只要在开启parpool前加入这一句,delete(gcp('nocreate'));
就没问题了。
Bug2: The interactive communicating job finished with no message
Starting parallel pool (parpool) using the 'local' profile ...
Error using parpool (line 149)
Parallel pool failed to start with the following error. For more detailed information, validate the profile 'local' in the Cluster Profile Manager.
Error in retrieve_bio_subs (line 26)
parpool(72); %开启并行计算
Caused by:
Error using parallel.internal.pool.InteractiveClient>iThrowWithCause (line 678)
Failed to initialize the interactive session.
Error using parallel.internal.pool.InteractiveClient>iThrowIfBadParallelJobStatus (line 818)
The interactive communicating job finished with no message.
解决方案:在命令行中加入:distcomp.feature( 'LocalUseMpiexec', false )