gpt4 book ai didi

r - makeCluster(多核)中的错误 : cannot open the connection

转载 作者:行者123 更新时间:2023-12-02 06:00:07 29 4
gpt4 key购买 nike

我有以下问题。

为什么在标准节点(最大核心 56)上提交作业时一切运行正常,但是当我将相同的作业/代码提交到 large_memory 节点(最大核心 128)时,我收到错误?

R 中的并行化代码:

> no_cores <- detectCores() - 1

> cl <- makeCluster(no_cores, outfile=paste0('./info_parallel.log'))

错误

Error in socketConnection(master, port = port, blocking = TRUE, open = "a+b",  :
cannot open the connection

Calls: <Anonymous> ... doTryCatch -> recvData -> makeSOCKmaster ->
socketConnection

In addition: Warning message:

In socketConnection(master, port = port, blocking = TRUE, open = "a+b", :
localhost:11232 cannot be opened
Execution halted

Error in unserialize(node$con) : error reading from connection
Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
Execution halted

Error in unserialize(node$con) : error reading from connection
Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
Execution halted
<小时/>

正如我所说,R 代码在标准节点上运行良好,因此我认为这是 large_memory 节点的问题。那会是什么?

最佳答案

终于解决了。

该错误是由R中的默认连接数限制引起的。连接数的默认值为128。这里,“连接数”是指代码中使用的每个节点的核心数。

而在代码中,错误发生在 cl <- makeCluster... 这行

no_cores <- detectCores() - 1

cl <- makeCluster(no_cores, outfile=paste0('./info_parallel.log'))

在这里,detectCores()将获得节点上的最大核心数。

在集群的标准节点中,每个节点的核心数小于128,这就是R代码可以在标准节点上良好运行的原因;而在我的例子中,large_memory 分区中每个节点的核心数为 128。默认达到核心数限制。所以错误显示为:

cannot open the connection

我尝试将核心数设置为 120,以便在 large_memory 节点上运行作业(最大核心数 = 128)。没有错误。该代码运行良好。

cl <- makeCluster(120, outfile=paste0('./info_parallel.log'))
# ^^^

谢谢!

关于r - makeCluster(多核)中的错误 : cannot open the connection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43900629/

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