【发布时间】:2014-06-05 00:41:04
【问题描述】:
我正在尝试在我们的集群上运行此作业,但我不断收到“'closure' 类型的对象不是子集”错误。它基本上在一堆节点上运行这个函数“do_1()”。我要设置子集的闭包对象称为“数据”,所以我认为这意味着 RData 文件没有在每个节点上读取(将这些单独的数据集中的每一个称为“数据”可能不是最佳实践,所以这是我的错) .
我将脚本尽可能地简化为基本内容,并显示在下方。当我提交作业时,它仍然会产生相同的错误。我认为在每个节点上读取单独的数据集时我不知道一些事情......我可能在调用 load() 时没有指定一些参数。也许“数据”数据集不在正确的名称空间或其他东西中……我不确定。任何想法将不胜感激。
library(parallel)
library(Rmpi)
np <- mpi.universe.size()
cl <- makeCluster(np, type = "MPI")
allFiles <- list.files("/bigtmp/trb5me/rdata_files/")
allFiles <- sapply(allFiles, function(string) paste("/bigtmp/trb5me/rdata_files/", string, sep = ""))
run_one_day <- function(daynum){
# do we want to subset days to not the first hour?
train <- data[[daynum]] * 10000
train
}
clusterExport(cl = cl, "run_one_day")
do_1 <- function(path_to_file){
if(!require(xts)){
install.packages("xts")
library(xts)
}
# load data
load(file=path_to_file)
# extract the symbol name so we cna save the results later
symbolName <- strsplit(path_to_file, "/")[[1]][5]
symbolName <- strsplit(symbolName, ".", fixed = T)[[1]][1]
# get the results
# there is also a function called data...so in this case it's length will be 1
mySequence <- 1:(length(data)-1)
myResults <- lapply(mySequence, run_one_day) #this is where the problem is!
# save the results
path_dest <- paste("/bigtmp/trb5me/mod1_results/", symbolName, ".RData", sep = "")
save(myResults, file = path_dest)
# remove everything from memory
rm(list=ls())
}
parLapply(cl, allFiles, do_1)
# turn off all the cluster stuff
stopCluster(cl)
mpi.exit()
【问题讨论】:
-
该函数中的错误来自哪里?尝试包括选项(错误=回溯)
-
等等,我明白了;没关系。
标签: r parallel-processing mpi cluster-computing