Complaints about slot "mode" rearing their head again

ETA: Further discussion probably best moved to this thread: Parallel chains not working; different behavior in RStudio and R from Terminal

When running a model with RStan using 4 chains in parallel, I get this error:

Error in FUN(X[[i]], ...) : 
  trying to get slot "mode" from an object of a basic class ("NULL") with no slots
Calls: sampling -> sampling -> .local -> sapply -> lapply -> FUN

The same model used to work with RStan and still runs with PyStan just fine.

It looks like this problem has shown up before: R 3.5.1 complains about slot "mode"

However, this time it’s happening with R 3.6.1 and RStan 2.18.2.

Any ideas on fixes or workarounds?

The slot mode thing is a red herring. The sampler returned NULL, which means it aborted. There is usually a message about why if you run it with chains = 1.

1 Like

Huh, now it just aborted almost right away. It used to be that at least a couple chains ran:

Chain 1: 
Chain 1: Gradient evaluation took 7e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.7 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Abort trap: 6

ETA: That was when running R at the Terminal. When running from RStudio, it actually works – but only if chains = 1. Otherwise, this is the output:

SAMPLING FOR MODEL 'jc' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 0.00011 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 1.1 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Error in unserialize(socklist[[n]]) : error reading from connection

SAMPLING FOR MODEL 'jc' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 0.000152 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 1.52 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)

SAMPLING FOR MODEL 'jc' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 7.9e-05 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.79 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 

SAMPLING FOR MODEL 'jc' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 0.000107 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 1.07 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 2: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 4: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 2: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 4: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 2: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 4: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 2: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 4: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 4: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 4: 
Chain 4:  Elapsed Time: 4.21187 seconds (Warm-up)
Chain 4:                3.00345 seconds (Sampling)
Chain 4:                7.21531 seconds (Total)
Chain 4: 
Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 3.86222 seconds (Warm-up)
Chain 2:                3.55775 seconds (Sampling)
Chain 2:                7.41997 seconds (Total)
Chain 2: 
Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Calls: <Anonymous> ... doTryCatch -> sendData -> sendData.SOCK0node -> serialize
Execution halted
Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Calls: <Anonymous> ... doTryCatch -> sendData -> sendData.SOCK0node -> serialize
Execution halted

It looks like only chains 2 and 4 actually ran to completion.

Can you post the Stan program?

I’m not sure I can. BTW, since I’ve started a different and arguably more thorough thread on the topic, this thread is pretty much defunct.