serializing stan models under R, platform windows

42 views
Skip to first unread message

Sebastian Weber

unread,
Jul 30, 2015, 9:14:05 AM7/30/15
to Stan users mailing list
Hi!

I am trying to provide a binary R library on a windows platform. So I serialized my stan model in question with

sm1 <- stan("log2bayes_single.stan", chains=0, data=NULL)
saveRDS(sm1, "log2bayes_single.rda")

and on the target machine I intended to run the code

l2b_fit <- readRDS("log2bayes_single.rda")
l2b <- stan(fit=l2b_fit, warmup=250, iter=1250)

However, this works on my own machine, but on the target machine this crashes R horribly with the message

"Error in withCallingHandlers(tryCatch ...
object '.rcpp_warning_recorder' not found

I would prefer not to rely on the auto_write feature and make calls ala stan("log2bayes_single.stan") while assuming that the auto_write stuff will take care of it. On the target machines, there will be no Rtools installed, only rstan; hence this model caching must work.

I would prefer to use rstan, but a solution could be to stick to cmdstan binaries. Or could during the package building a compile step of the C++ translated stan model be integrated?

Many thanks for any pointers.

Best,
Sebastian

Ben Goodrich

unread,
Jul 30, 2015, 10:30:10 AM7/30/15
to Stan users mailing list, sdw....@gmail.com, sdw....@gmail.com
On Thursday, July 30, 2015 at 9:14:05 AM UTC-4, Sebastian Weber wrote:
I would prefer not to rely on the auto_write feature and make calls ala stan("log2bayes_single.stan") while assuming that the auto_write stuff will take care of it. On the target machines, there will be no Rtools installed, only rstan; hence this model caching must work.

The serialization and deserialization of compiled code won't work across platforms. It might work if you compiled the model on a Windows machine with Rtools but only if the other machine had the same bitness.

Ben

Sebastian Weber

unread,
Jul 30, 2015, 11:14:25 AM7/30/15
to Stan users mailing list, goodri...@gmail.com
It is the same platform - the two laptops are both Windows 7 installations (company laptops, so the installation should be very similar). If I solve this, then I can ditch JAGS ...

So, yes, I compiled it with Rtools 3.0 on Windows (the model and rstan). It should work, no?

Sebastian

Avraham Adler

unread,
Jul 30, 2015, 11:20:04 AM7/30/15
to Stan users mailing list, sdw....@gmail.com, goodri...@gmail.com, sdw....@gmail.com
As per <http://stackoverflow.com/questions/28966800/error-withcallinghandlers-crashing-r>, have you tried re-installing Rcpp? It has just been updated to version 0.12.

Avi

Sebastian Weber

unread,
Jul 30, 2015, 12:09:11 PM7/30/15
to Stan users mailing list, goodri...@gmail.com, avraha...@gmail.com
Cool! It works now for me!

I upgraded Rcpp and I ensured that on the target machine Rcpp, RcppEigen, inline & BH are freshly installed. And now it does work, wonderful!

Thanks a lot ... now it's time to switch code to Stan...
Reply all
Reply to author
Forward
0 new messages