Error in unserialize(socklist[[n]]) : error reading from connection Error in serialize(data, node$con, xdr = FALSE) : error writing to connection

I am trying to run sampling for 40 iterations and each time i get the following error:

Error in unserialize(socklist[[n]]) : error reading from connection
Error in serialize(data, node$con, xdr = FALSE) :
error writing to connection
When i try to do it with chains=1 it crushes…

I used all the recommended commands :
rstan_options(auto_write=TRUE)
options(mc.cores=parallel::detectCores())

Output of sessionInfo:
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rstan_2.18.2 StanHeaders_2.18.1 ggplot2_3.1.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 pillar_1.3.1 compiler_3.5.2 plyr_1.8.4 bindr_0.1.1
[6] prettyunits_1.0.2 tools_3.5.2 pkgbuild_1.0.2 tibble_2.0.1 gtable_0.2.0
[11] pkgconfig_2.0.2 rlang_0.3.1 cli_1.0.1 rstudioapi_0.9.0 parallel_3.5.2
[16] yaml_2.2.0 loo_2.0.0 bindrcpp_0.2.2 gridExtra_2.3 withr_2.1.2
[21] dplyr_0.7.8 stats4_3.5.2 grid_3.5.2 tidyselect_0.2.5 glue_1.3.0
[26] inline_0.3.15 R6_2.3.0 processx_3.2.1 purrr_0.2.5 callr_3.1.1
[31] magrittr_1.5 codetools_0.2-15 scales_1.0.0 ps_1.3.0 matrixStats_0.54.0
[36] assertthat_0.2.0 colorspace_1.4-0 lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4

I would really appreciate any help.
Thanks

1 Like

When you do chains = 1, is there an error message? Also, are you using integrate_bdf?

No…R crushes ;(

Now it worked normally with chains=1…
Its strange because when i place priors in my hyperparameters in the model and i put chains=1 R crushes…
When i don’t, it only work for chain=1 and for a small amount of iterations.
Is there a way to fix this?
Thank you

I’m getting the same error (everytime) when running the ‘blocker’ example from RStudio on Version 1.2.1330.
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763) (5 Core, Intel Core i7-8700)

ie.
fit <- stan(file = ‘blocker.stan’, data = blocker_dat)
Error in unserialize(socklist[[n]]) : error reading from connection
Error in serialize(data, node$con, xdr = FALSE) :
error writing to connection

The error goes away when I run on a single core.

Error in unserialize(socklist[[n]]) : error reading from connection
Error in serialize(data, node$con, xdr = FALSE)

Can you do any models in parallel? I would guess there is some permissions thing that is preventing reading the compiled model from the disk in the child processes.

I tried running RStudio as administrator, same consistent error with blocker model. Inferestingly, I don’t get this error when running the 8schools model in parallel (i.e. ‘options(mc.cores = parallel::detectCores())’).

No issues on same machine running Linux.

Maybe you have an old compiled instance of the blocker model? Try deleting blocker.rds in that folder.

I removed ‘blocker.rds’ and re-ran. After a few seconds, the following appears in the ‘Viewer’ pane in RStudio:

Click the Refresh button to see progress of the chains

starting worker pid=3112 on localhost:11763 at 11:54:33.691

starting worker pid=19984 on localhost:11763 at 11:54:33.820

starting worker pid=22368 on localhost:11763 at 11:54:33.947

The fit stops with the same error.

What happens if you hit refresh?

After clicking refresh, the viewer pane displays the following, then quits with the error message.

SAMPLING FOR MODEL ‘blocker’ NOW (CHAIN 1).

Chain 1:

Chain 1: Gradient evaluation took 0 seconds

Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.

Chain 1: Adjust your expectations accordingly!

Chain 1:

Chain 1:

Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)

SAMPLING FOR MODEL ‘blocker’ NOW (CHAIN 2).

Chain 2:

Chain 2: Gradient evaluation took 0 seconds

Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.

Chain 2: Adjust your expectations accordingly!

Chain 2:

Chain 2:

Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)

SAMPLING FOR MODEL ‘blocker’ NOW (CHAIN 3).

Chain 3:

Chain 3: Gradient evaluation took 0 seconds

Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.

Chain 3: Adjust your expectations accordingly!

Chain 3:

Chain 3:

Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)

SAMPLING FOR MODEL ‘blocker’ NOW (CHAIN 4).

Chain 4:

Chain 4: Gradient evaluation took 0 seconds

Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0 seconds.

Chain 4: Adjust your expectations accordingly!

Chain 4:

Chain 4:

Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)

On a hunch, I uninstalled the ‘Killer Control Center Application’ that came factory installed. the error now no longer occurs.

https://www.dell.com/support/home/us/en/19/drivers/driversdetails?driverid=gw0hw&lwp=rt

I haven’t confirmed by re-installing, but thought I’d report here in case this bites someone else.

Unfortunately, without making any known changes to my system, the error has returned and cannot be blamed on the ‘Killer Control Center Application’.

I don’t know anything about the “Killer Control Center Application”. Can you run

example(parLapplyLB, package = "parallel", run.dontrun = TRUE)

or that system? Can you run stan with cores = 1?

1 Like

Yes to both. Thanks.

bgoodri

April 1

I don’t know anything about the “Killer Control Center Application”. Can you run

example(parLapplyLB, package = "parallel", run.dontrun = TRUE)

Yes, this example from "parallel’ runs without error.



or that system? Can you run stan with cores = 1?

Yes, when I set “options(mc.cores = 1)”, the blocker example runs without error.

When I substitute “options(mc.cores = parallel::detectCores())”, I get:

fit <- stan(file = ‘blocker.stan’, data = blocker_dat)

Error in unserialize(socklist[[n]]) : error reading from connection

Error in serialize(data, node$con, xdr = FALSE) :

error writing to connection

Did anyone find a way to resolve this? I’ve had the same error, and it occurs when I loop over multiple data sets and attempt to apply the same model. The first data always works fine, but sometimes (yet not always) subsequent data yields the same error message as above. If I restart R and apply the model to the same data again, it works fine. But that’s not a long-term solution.

Same here…

2 Likes

I encountered the same error. I can run "example(parLapplyLB, package = “parallel”, run.dontrun = TRUE) " without error. And when I set “options(mc.cores = 1)”, my stan model could run, but could not return any result. And When set “options(mc.cores =1)”, other examples run well before now return a strange results for parameters.

Same here. Did you find any solution?

Unfortunately, I continue to get this error on Windows 10 after updating to rstan 2.19.2.

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)