Repository navigation
Closed
Labels
Description
I am developing a package and the functionality works great on my local machine. When I try to test it on a server, where I have R installed, it crashes with that error. Here is the function from within the package:
#' @importFrom foreach foreach %dopar%
#' @importFrom parallel makeCluster stopCluster
#' @import doFuture
#' @import future
sc3min_calc_dists.SingleCellExperiment<- function(object) {
dataset <- get_processed_dataset(object)
# check whether in the SVM regime
if (!is.null(metadata(object)$sc3min$svm_train_inds)) {
dataset <- dataset[, metadata(object)$sc3min$svm_train_inds]
}
# NULLing the variables to avoid notes in R CMD CHECK
i <- NULL
distances <- c("euclidean", "pearson", "spearman")
message("Calculating distances between the cells...")
if (metadata(object)$sc3min$n_cores > length(distances)) {
n_cores <- length(distances)
} else {
n_cores <- metadata(object)$sc3min$n_cores
}
doFuture::registerDoFuture()
cl <- parallel::makeCluster(n_cores, outfile = "")
future::plan(future::cluster, workers = cl)
dists <- foreach::foreach(i = distances) %dopar% {
try({
calculate_distance(dataset, i)
})
}
# stop local cluster
parallel::stopCluster(cl)
names(dists) <- distances
metadata(object)$sc3min$distances <- dists
return(object)
}
#' @rdname sc3min_calc_dists
#' @aliases sc3min_calc_dists
setMethod("sc3min_calc_dists", signature(object = "SingleCellExperiment"), sc3min_calc_dists.SingleCellExperiment)`
Here is the output from sessionInfo() of the working version on my local machine:
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS
Matrix products: default
BLAS: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRblas.so
LAPACK: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] SC3min_1.0.1 SingleCellExperiment_1.4.1 SummarizedExperiment_1.12.0 DelayedArray_0.8.0 BiocParallel_1.16.6 matrixStats_0.54.0
[7] GenomicRanges_1.34.0 GenomeInfoDb_1.18.2 IRanges_2.16.0 S4Vectors_0.20.1 pcaMethods_1.74.0 Biobase_2.42.0
[13] BiocGenerics_0.28.0 RevoUtils_11.0.1 RevoUtilsMath_11.0.0
loaded via a namespace (and not attached):
[1] bitops_1.0-6 fs_1.2.6 usethis_1.4.0 devtools_2.0.1 doParallel_1.0.14 RColorBrewer_1.1-2 httr_1.4.0
[8] rprojroot_1.3-2 tools_3.5.1 backports_1.1.3 doRNG_1.7.1 R6_2.4.0 KernSmooth_2.23-15 lazyeval_0.2.1
[15] colorspace_1.4-0 withr_2.1.2 tidyselect_0.2.5 prettyunits_1.0.2 processx_3.3.0 curl_3.3 compiler_3.5.1
[22] cli_1.0.1 desc_1.2.0 pkgmaker_0.27 caTools_1.17.1.2 scales_1.0.0 mvtnorm_1.0-10 DEoptimR_1.0-8
[29] robustbase_0.93-3 callr_3.1.1 stringr_1.4.0 digest_0.6.18 XVector_0.22.0 htmltools_0.3.6 rrcov_1.4-7
[36] pkgconfig_2.0.2 bibtex_0.4.2 WriteXLS_4.1.0 sessioninfo_1.1.1 rlang_0.3.1 rstudioapi_0.9.0 shiny_1.2.0
[43] jsonlite_1.6 gtools_3.8.1 dplyr_0.8.0.1 RCurl_1.95-4.12 magrittr_1.5 GenomeInfoDbData_1.2.0 Matrix_1.2-14
[50] Rcpp_1.0.0 munsell_0.5.0 stringi_1.3.1 yaml_2.2.0 zlibbioc_1.28.0 pkgbuild_1.0.2 gplots_3.0.1.1
[57] plyr_1.8.4 grid_3.5.1 promises_1.0.1 gdata_2.18.0 listenv_0.7.0 crayon_1.3.4 lattice_0.20-35
[64] pillar_1.3.1 knitr_1.22 ps_1.3.0 rngtools_1.3.1 codetools_0.2-15 pkgload_1.0.2 glue_1.3.0
[71] doFuture_0.6.0 data.table_1.12.0 remotes_2.0.2 BiocManager_1.30.4 httpuv_1.4.5.1 foreach_1.4.4 testthat_2.0.1
[78] purrr_0.3.1 gtable_0.2.0 future_1.9.0 assertthat_0.2.0 ggplot2_3.1.0 githubinstall_0.2.2 xfun_0.5
[85] mime_0.6 xtable_1.8-3 e1071_1.7-0.1 later_0.8.0 pcaPP_1.9-73 class_7.3-14 tibble_2.0.1
[92] pheatmap_1.0.12 iterators_1.0.10 registry_0.5-1 memoise_1.1.0 cluster_2.0.7-1 globals_0.12.4 ROCR_1.0-7
Here is the error I get when running on the server:
Setting SC3min parameters...
Calculating distances between the cells...
Error: Unexpected result (of class ‘snow-try-error’ != ‘FutureResult’) retrieved for ClusterFuture future (label = ‘<none>’, expression = ‘{; doFuture::registerDoFuture(); lapply(seq_along(...future.x_ii), FUN = function(jj) {; ...future.x_jj <- ...future.x_ii[[jj]]; i <- NULL; ...future.env <- environment(); ...; }, error = identity); }); }’): there is no package called ‘SC3min’
Traceback:
1. SC3min::sc3min(sce, ks = 10)
2. SC3min::sc3min(sce, ks = 10)
3. sc3min_calc_dists(object)
4. sc3min_calc_dists(object)
5. foreach::foreach(i = distances) %dopar% {
. try({
. calculate_distance(dataset, i)
. })
. }
6. e$fun(obj, substitute(ex), parent.frame(), e$data)
7. lapply(fs, FUN = value, signal = FALSE)
8. FUN(X[[i]], ...)
9. value.Future(X[[i]], ...)
10. result(future)
11. result.ClusterFuture(future)
Here is the sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS
Matrix products: default
BLAS: /data/home/spec-vahek17/anaconda3/lib/R/lib/libRblas.so
LAPACK: /data/home/spec-vahek17/anaconda3/lib/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] pheatmap_1.0.12 scater_1.10.1
[3] ggplot2_3.1.0 SingleCellExperiment_1.4.1
[5] SummarizedExperiment_1.12.0 DelayedArray_0.8.0
[7] BiocParallel_1.16.6 matrixStats_0.54.0
[9] GenomicRanges_1.34.0 GenomeInfoDb_1.18.2
[11] IRanges_2.16.0 S4Vectors_0.20.1
[13] SC3min_1.0.1 pcaReduce_1.0
[15] mclust_5.4.2 mnormt_1.5-5
[17] pcaMethods_1.74.0 Biobase_2.42.0
[19] BiocGenerics_0.28.0 RevoUtils_11.0.1
[21] RevoUtilsMath_11.0.0
loaded via a namespace (and not attached):
[1] ggbeeswarm_0.6.0 colorspace_1.4-0 class_7.3-14
[4] rprojroot_1.3-2 IRdisplay_0.7.0 XVector_0.22.0
[7] base64enc_0.1-3 fs_1.2.6 listenv_0.7.0
[10] remotes_2.0.2 mvtnorm_1.0-10 codetools_0.2-15
[13] doParallel_1.0.13 robustbase_0.93-3 installr_0.21.1
[16] pkgload_1.0.2 IRkernel_0.8.15.9000 jsonlite_1.5
[19] cluster_2.0.7-1 HDF5Array_1.10.1 shiny_1.1.0
[22] rrcov_1.4-7 compiler_3.5.1 backports_1.1.2
[25] assertthat_0.2.0 Matrix_1.2-14 lazyeval_0.2.1
[28] cli_1.0.0 later_0.7.3 htmltools_0.3.6
[31] prettyunits_1.0.2 tools_3.5.1 bindrcpp_0.2.2
[34] gtable_0.2.0 glue_1.3.0 GenomeInfoDbData_1.2.0
[37] reshape2_1.4.3 dplyr_0.7.6 doRNG_1.7.1
[40] Rcpp_0.12.18 gdata_2.18.0 DelayedMatrixStats_1.4.0
[43] iterators_1.0.10 stringr_1.3.1 globals_0.12.4
[46] ps_1.3.0 testthat_2.0.1 mime_0.5
[49] rngtools_1.3.1 gtools_3.8.1 WriteXLS_4.1.0
[52] devtools_2.0.1 future_1.9.0 DEoptimR_1.0-8
[55] zlibbioc_1.28.0 scales_1.0.0 promises_1.0.1
[58] rhdf5_2.26.2 RColorBrewer_1.1-2 curl_3.2
[61] gridExtra_2.3 memoise_1.1.0 pkgmaker_0.27
[64] stringi_1.2.4 desc_1.2.0 pcaPP_1.9-73
[67] foreach_1.5.0 e1071_1.7-0.1 caTools_1.17.1.1
[70] pkgbuild_1.0.2 bibtex_0.4.2 repr_0.19.2
[73] rlang_0.2.1 pkgconfig_2.0.1 bitops_1.0-6
[76] evaluate_0.11 lattice_0.20-35 Rhdf5lib_1.4.2
[79] ROCR_1.0-7 purrr_0.2.5 bindr_0.1.1
[82] processx_3.2.1 tidyselect_0.2.4 plyr_1.8.4
[85] magrittr_1.5 R6_2.2.2 gplots_3.0.1.1
[88] pbdZMQ_0.3-3 pillar_1.3.0 withr_2.1.2
[91] RCurl_1.95-4.11 tibble_1.4.2 crayon_1.3.4
[94] uuid_0.1-2 KernSmooth_2.23-15 doFuture_0.6.0
[97] viridis_0.5.1 usethis_1.4.0 grid_3.5.1
[100] callr_3.1.1 digest_0.6.15 xtable_1.8-2
[103] httpuv_1.4.5 munsell_0.5.0 beeswarm_0.2.3
[106] viridisLite_0.3.0 registry_0.5-1 vipor_0.4.5
[109] sessioninfo_1.1.1
Activity
HenrikBengtsson commentedon Mar 11, 2019
Before anything else, could you please fix up the Markdown formatting to make it more readable?
[-]Error: Unexpected result (of class ‘snow-try-error’ != ‘FutureResult’) retrieved for ClusterFuture future (label = ‘<none>’, expression = ‘{; doFuture::registerDoFuture(); lapply(seq_along(...future.x_ii), FUN = function(jj) {; ...future.x_jj <- ...future.x_ii[[jj]]; i <- NULL; ...future.env <- environment(); ...; }, error = identity); }); }’): there is no package called ‘SC3min’[/-][+]Error: Unexpected result (of class ‘snow-try-error’ != ‘FutureResult’) retrieved for ClusterFuture future ([...]): there is no package called ‘SC3min’[/+]brickyyyy commentedon Mar 12, 2019
Has been updated.
HenrikBengtsson commentedon Mar 12, 2019
Both doFuture and future are out of date.
Same here.
I would start by updating all future-related packages.
brickyyyy commentedon Mar 13, 2019
Hi, I have updated all packages on both, it still works on my local pc and on the server it doesn't.
HenrikBengtsson commentedon Mar 13, 2019
What is the exact error message now and what
plan()is used on both?brickyyyy commentedon Mar 13, 2019
The code is the same on both, I have a package on github, that I am able to run on my local machine, but when I install it on the server, even after updating the future-related packages, it still shows the same error as reported previously.
HenrikBengtsson commentedon Mar 13, 2019
My bad, I now see that the
plan()is set inside the code:So, the same kind of
n_coresPSOCK localhost workers on both systems.Are you 100% sure you get the exact same error message, because I've spend a lot of time updating future to give more informative error message. At a minimum, they should be rephrased since future 1.9.0.
Moreover, are you really sure you've updated the packages? The reason why I ask, is that you claimed "I get the following error even after updating all packages." in #220 (comment), but from the above session infos it's clear that that update failed one way or the other.
Continuing, your local and your remote systems are very similar, e.g. they both run 64-bit R 3.5.1. The only way I see they differ is that the former is on Ubuntu 18.04 and the latter on Ubuntu 16.04. But, more importantly, if you both systems have all packages up to date and you run the same code, then the
sessionInfo()should be the same. The only valid reason I can see them differing is that on the failing system the program is interrupted and won't load additional packages downstream. However, in your output your cluster session has more packages loaded than your local machine. This suggests that you are not running the same code.Finally, at the end of the day, the error message suggests "there is no package called ‘SC3min’". This means that the background R worker does not find a 'SC3min' package on the
.libPaths(). It could be that you use some non-default library paths on the cluster.You could try to set
plan(sequential)to at least see if your code runs in non-parallel mode. That will rule out a lot of things. If you still get the error, then the problem is definitely not related to the future framework.brickyyyy commentedon Mar 13, 2019
Okay, I restarted the kernel and now the message is different, sorry for the inconvenience:
HenrikBengtsson commentedon Mar 13, 2019
I suspect that you've got customized
.libPaths()/R_LIBS/... in place that are not picked up by the background R workers, which in turn causesdoFutureand other packages not to be found. Note that this time it says 'doFuture' cannot be found, previously it was your 'SC3min' - you seems to have a moving target too.I recommend that you go back to the basics and make sure you can run basic parallel processes.
Then
and
I suspect you'll see the same issue with this much smaller example. That'll give you something to work with. Also, as I said above, test with
plan(sequential)as a lower bound.brickyyyy commentedon Mar 14, 2019
Hi Henrik,
All 3 chunks work locally again. The first 2 chunks work on the server, the third fails like this.
That's the session info. I tried uninstalling, installing again, restarting the kernel and the error still remains.
HenrikBengtsson commentedon Mar 14, 2019
On the cluster, what does this output:
Also, what is your
.libPaths()?brickyyyy commentedon Mar 14, 2019
The output:
Seems very weird since it finds the package location.
HenrikBengtsson commentedon Mar 14, 2019
And ...
brickyyyy commentedon Mar 14, 2019
That is the output.
Seems like it takes the packages from the version of R installed on the server and not from my personal installation of R from Anaconda.
HenrikBengtsson commentedon Mar 14, 2019
So, this is unrelated to the future framework. You'll get the same with:
You might not even be running the same R binary as you think; look at:
PS. I'm not a big fan of installing R via Anaconda. For instance, the fact that your
.libPaths()[1]("/data/home/spec-vahek17/anaconda3/lib/R/library") is not specific to a given R x.y version is concerning. When you upgrade to R 3.6.0, your R 3.5.x and R 3.6.x package installations will clash! I typically install R from source when I don't have admin rights to install usingsudo apt install ....brickyyyy commentedon Mar 14, 2019
I was told to install it through anaconda, you are right.
With the same output as before
That gives 2 different locations:
HenrikBengtsson commentedon Mar 14, 2019
You can try to force the workers to use the same R as the master process:
but I'd think that's already the default. You might also want to inspect your environment variables. Look for
R_*one, e.g.R_HOME?You might be able to troubleshoot better if you use
future::makeClusterPSOCK()- it's backward compatibile withparallel::makeCluster()but have more options, e.g.I don't think I can do much more for you - the take-home message is that Anaconda (or some R hacky settings you haven't told me about) is messing things up for you. If
/usr/lib/Ris up-to-date, I'd use that instead of Anaconda R.brickyyyy commentedon Mar 14, 2019
Thank you so much for your help! I will try to force it to use the Anaconda libs :)