I am using the atakrig package. When setting the number of cores to 8 for parallel computation I am getting this error: 0%Error in serialize(data, node$con) : error writing to connection
. I am getting this error when I am using the package's function ataStartCluster()
(i.e., parallel calculations).
I don't think it's a memory issue because:
-
even with the package's dataset I am getting the same error.
-
On my other laptop, which has 4gb of RAM and Windows 10, the code runs just fine no matter the size of the dataset.
The laptop I am currently using is a Windows 11 machine with 16gb of RAM.
I tried several things like:
cl <- parallel::makeCluster(8, type = "PSOCK")
or
ncpu <- parallel::detectCores()/4L
cl <- parallel::makePSOCKcluster(ncpu) ## make PSOCK cluster
doSNOW::registerDoSNOW(cl)
options(ataKrigCluster=cl)
or I tried to uninstall and re-install atakrig
and parallel
but nothing seems to work. The strange thing is that a few months ago, I had no issue with the package and I was using way larger datasets than now.
Any idea of what might be causing this error? Below is the code using the package's dataset and the session info. If someone needs more information about my laptop, please let me know and I'll share it.
library(atakrig)
library(terra)
rpath <- system.file("extdata", package="atakrig")
aod3k <- rast(file.path(rpath, "MOD04_3K_A2017042.tif"))
aod10 <- rast(file.path(rpath, "MOD04_L2_A2017042.tif"))
aod3k.d <- discretizeRaster(aod3k, 1500)
aod10.d <- discretizeRaster(aod10, 1500)
grid.pred <- discretizeRaster(aod3k, 1500, type = "all")
aod3k.d$areaValues$value <- log(aod3k.d$areaValues$value)
aod10.d$areaValues$value <- log(aod10.d$areaValues$value)
## area-to-area Kriging ---# point-scale variogram from combined AOD-3k and AOD-10
aod.combine <- rbindDiscreteArea(x = aod3k.d, y = aod10.d)
vgm.ok_combine <- deconvPointVgm(aod.combine, model="Exp", ngroup=12, rd=0.75)
# point-scale cross-variogram
aod.list <- list(aod3k=aod3k.d, aod10=aod10.d)
aod.list <- list(aod3k=aod3k.d, aod10=aod10.d)
vgm.ck <- deconvPointVgmForCoKriging(aod.list, model="Exp", ngroup=12, rd=0.75,fixed.range = 9e4)
# prediction
cl <- parallel::makeCluster(8, type = "PSOCK")
pred.ataok <- ataKriging(aod10.d, grid.pred, vgm.ck$aod10, showProgress = TRUE, nopar = FALSE)
parallel::stopCluster(cl)
Session info
R version 4.5.0 (2025-04-11 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: Europe/London
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] terra_1.8-42 atakrig_0.9.8.1
loaded via a namespace (and not attached):
[1] DBI_1.2.3 KernSmooth_2.23-26 sf_1.0-20 doSNOW_1.0.20 zoo_1.8-14 spacetime_1.3-3 xts_0.14.1
[8] e1071_1.7-16 snow_0.4-4 sp_2.2-0 gstat_2.1-3 grid_4.5.0 classInt_0.4-11 foreach_1.5.2
[15] FNN_1.1.4.1 intervals_0.15.5 compiler_4.5.0 codetools_0.2-20 Rcpp_1.0.14 rstudioapi_0.17.1 lattice_0.22-7
[22] class_7.3-23 parallel_4.5.0 magrittr_2.0.3 tools_4.5.0 proxy_0.4-27 iterators_1.0.14 units_0.8-7