在Matlab中,扩展最大为12个可用的logic cores的方法;To terminate the existing session, use ‘delete(gc​p(‘nocreat​e‘))

文章讲述了在Matlab中遇到的两个问题:一是如何设置最大可用核心数以利用多核,二是如何处理因同时打开多个交互式会话导致的错误。解决方法包括使用maxNumCompThreads函数和关闭未使用的parpool。另一个问题是关于MPIexec的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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(gc​p('nocreat​e'))'
这个错误是因为我在之前开启了一个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 )

interface

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值