如何解决R未来的错误"error in future$uuid : object of type closure is not subsettable"



当尝试在R中用并行后端注册future时,我收到以下错误消息:

Error in future$uuid : object of type 'closure' is not subsettable

以前使用future总是可以的。

我的代码:

# Previously installed future, doFuture, parallel and doParallel packages
library(future)
library(doFuture)
registerDoFuture()
no.clusters = max(detectCores()-4,1)
cl = parallel::makeCluster(no.clusters)
plan(cluster, workers = cl)

运行plan命令时出错。重新启动RStudio可以解决一次运行的问题,但在同一会话中再次运行代码会导致错误。显然,我不希望每次我想使用并行编程时都重新启动RStudio并导入所有数据等,因此将不胜感激

追溯:

16: FutureCondition(message = message, call = call, uuid = uuid, 
future = future)
15: FutureError(sprintf("Cannot resolve %s (%s), because the connection to the worker is corrupt: %s", 
class(x)[1], label, attr(isValid, "reason", exact = TRUE)), 
future = future)
14: stop(FutureError(sprintf("Cannot resolve %s (%s), because the connection to the worker is corrupt: %s", 
class(x)[1], label, attr(isValid, "reason", exact = TRUE)), 
future = future))
13: resolved.ClusterFuture(future, run = FALSE)
12: resolved(future, run = FALSE)
11: collectValues(where, futures = futures, firstOnly = TRUE)
10: FutureRegistry(reg, action = "collect-first", earlySignal = TRUE)
9: await()
8: requestNode(await = function() {
FutureRegistry(reg, action = "collect-first", earlySignal = TRUE)
}, workers = workers)
7: run.ClusterFuture(future)
6: run(future)
5: strategy(..., envir = envir, workers = workers)
4: evaluator(NA, label = "future-plan-test", globals = FALSE, lazy = FALSE)
3: plan_init()
2: plan_set(newStack, skip = .skip, cleanup = .cleanup, init = .init)
1: plan(cluster, workers = cl)

future本质上是在后台创建R进程,以便于并行计算。我相信,当您中止主进程时,其中一个子进程R仍在处理某些事情时,可能会出现此错误。让进程完成或在再次运行之前手动终止子进程R可能会解决此问题。

最新更新