함수를 찾을 수 없어 캐럿 내 열차의 병렬 실행이 실패합니다.
-
21-12-2019 - |
문제
어제 R 패키지를 업데이트했는데 그 이후로 열차 기능의 병렬 실행이 실패했습니다.
워커 내에서 호출되는 일부 기능을 사용할 수 없는 것 같습니다.이러한 함수는 최소한 flatTable 및 probFunction입니다.
프로덕션 컴퓨터에서 이 문제가 발생했으며 깨끗한 Windows 7 x64 VM에서 이 문제를 재현할 수 있었습니다.
아래에 최소한의 작업 예제를 추가했습니다.친애하는 stackoverflow 사용자 여러분:도움을 주시면 감사하겠습니다!
# R 3.0.2 x64, RStudio Version 0.98.490, Windows 7 x64
data(iris)
library(caret) # 6.0-21
library(doParallel) # 1.0.6
model <- "rf"
# Fail
?probFunction
?flatTable
fitControl <- trainControl(
method = "repeatedcv"
, number = 5 ## 5-fold CV
, repeats = 1 ## repeated one times
, verboseIter =TRUE
)
#### Sequential Version ####
# Runs
train(Species ~ ., data = iris, method = model, trControl = fitControl)
#### Parallelized version ####
# Fails with
# Error in e$fun(obj, substitute(ex), parent.frame(), e$data) :
# worker initialization failed: Error in eval(expr, envir, enclos): could not find function "flatTable"
cl <- makeCluster(3)
registerDoParallel(cl)
train(Species ~ ., data = iris, method = model, trControl = fitControl)
stopCluster(cl)
# Fails with
# Error in { : task 1 failed - "could not find function "probFunction""
fitControl <- trainControl(
method = "repeatedcv"
, number = 5 ## 5-fold CV
, repeats = 1 ## repeated one times
, verboseIter =TRUE
, classProbs = TRUE
)
cl <- makeCluster(3)
registerDoParallel(cl)
train(Species ~ ., data = iris, method = model, trControl = fitControl)
stopCluster(cl)
#### Again sequential version ####
# Fails with
# Error in summary.connection(connection) : invalid connection
train(Species ~ ., data = iris, method = model, trControl = fitControl)
R 세션 정보
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] e1071_1.6-1 class_7.3-9 randomForest_4.6-7 doParallel_1.0.6 iterators_1.0.6
[6] foreach_1.4.1 caret_6.0-21 ggplot2_0.9.3.1 lattice_0.20-23
loaded via a namespace (and not attached):
[1] car_2.0-19 codetools_0.2-8 colorspace_1.2-4 compiler_3.0.2 dichromat_2.0-0
[6] digest_0.6.4 grid_3.0.2 gtable_0.1.2 labeling_0.2 MASS_7.3-29
[11] munsell_0.4.2 nnet_7.3-7 plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5
[16] reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.2
해결책
발생하는 오류는 doParallel, doSNOW 및 doMPI를 사용할 때 캐럿 6.0-21의 버그로 인해 발생합니다.R-forge의 버전 6.0-22에서 수정되었지만 아직 CRAN에는 출시되지 않았습니다.새 버전이 출시될 때까지 기다리지 않으려면 다음을 수행할 수 있습니다.
- 캐럿 5.x로 다운그레이드
- R-forge에서 캐럿 6.0-22 설치
- doParallel 대신 R-forge에서 doSNOW 1.0.10을 설치하고 사용하십시오.
이 문제는 CRAN 정책의 변경으로 인해 발생했습니다. :::
동일한 패키지 내에서 내보내지 않은 함수를 참조하는 경우에도 마찬가지입니다.
업데이트
Caret 6.0-22는 2014년 1월 18일에 CRAN에 출시되었습니다.이렇게 하면 doSNOW 및 유사한 병렬 백엔드와 함께 캐럿을 사용하여 보고된 문제가 해결됩니다.
제휴하지 않습니다 StackOverflow