unexpected RStan warnings

62 views
Skip to first unread message

Bob Carpenter

unread,
Apr 25, 2016, 3:50:40 PM4/25/16
to stan...@googlegroups.com
I still can't get RStan to avoid recompilation for multiple runs.
If I set the save_dso thing, it saves it and it's available in
the next session, but I can't seem to get it to reuse a compiled
model in the same session. So I want to check that I'm not doing
something wrong.


I followed the instructions after loading the library:

> library(rstan)
Loading required package: ggplot2
rstan (Version 2.9.0-3, packaged: 2016-02-11 15:54:41 UTC, GitRev: 05c3d0058b6a)
For execution on a local, multicore CPU with excess RAM we recommend calling
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores()) and


and ran this:

> library(rstan);
> options(mc.cores = 4);
> rstan_options(auto_write = TRUE);
> fit <-
stan("exon-diff-hier.stan",
data=c("I", "J", "K", "N", "y"),
chains=4, iter=500, refresh=50,
control=list(stepsize=0.1, adapt_delta=0.95), fit=fit);


It ran in parallel, but when it was done, it dumped out the following
warning. Might this have something to do with why it recompiles
every time? (I have switched back to the fit=fit argument because I
couldn't get the auto recompile to work).


> Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported? Making a copy in package ‘.GlobalEnv’
Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported? Making a copy in package ‘.GlobalEnv’
Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported? Making a copy in package ‘.GlobalEnv’
Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported? Making a copy in package ‘.GlobalEnv’


I'm willing to run whatever diagnostics you think necessary.
Maybe Jonah or Andrew knows how to make this work on a Mac? Daniel's
having the same problem as I am.

- Bob



Andrew Gelman

unread,
Apr 25, 2016, 4:16:25 PM4/25/16
to stan...@googlegroups.com
It works sometimes for me (being able to reuse a compiled model in the same R session) but not always.
A
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Bob Carpenter

unread,
Apr 25, 2016, 4:31:28 PM4/25/16
to stan...@googlegroups.com
It never works for me.

- Bob

Ben Goodrich

unread,
Apr 25, 2016, 5:11:07 PM4/25/16
to stan development mailing list
On Monday, April 25, 2016 at 3:50:40 PM UTC-4, Bob Carpenter wrote:
> Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported?  Making a copy in package ‘.GlobalEnv’
Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported?  Making a copy in package ‘.GlobalEnv’
Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported?  Making a copy in package ‘.GlobalEnv’
Warning message:
class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported?  Making a copy in package ‘.GlobalEnv’

Those particular warnings are due to having an old R / Rcpp. I don't think they have anything to do with the recompilation. But I would have to look at an affected computer.

Ben

Bob Carpenter

unread,
Apr 25, 2016, 8:58:20 PM4/25/16
to stan...@googlegroups.com
You're right --- upgrading Rcpp and R and reinstalling
RStan did the trick.

There's still the problem that it's recompiling every time.
Is there something I need to do to enable it to find an
existing compiled version?

- Bob

Ben Goodrich

unread,
Apr 25, 2016, 11:23:01 PM4/25/16
to stan development mailing list
On Monday, April 25, 2016 at 8:58:20 PM UTC-4, Bob Carpenter wrote:
You're right --- upgrading Rcpp and R and reinstalling
RStan did the trick.

There's still the problem that it's recompiling every time.
Is there something I need to do to enable it to find an
existing compiled version?

No, that is supposed to work automatically, at least within a session and then across sessions if you specify rstan_options(auto_write = TRUE). I don't know what is going on with your laptop. As far as I know, Jonah is not having this problem.

Ben
 

Jonah Gabry

unread,
Apr 27, 2016, 1:01:28 AM4/27/16
to stan development mailing list
I didn't recall it being a problem but I'm now noticing that this does actually happen for me but it seems to be just occasionally.

Ben Goodrich

unread,
Apr 27, 2016, 8:02:03 AM4/27/16
to stan development mailing list
On Wednesday, April 27, 2016 at 1:01:28 AM UTC-4, Jonah Gabry wrote:
I didn't recall it being a problem but I'm now noticing that this does actually happen for me but it seems to be just occasionally.

You need to

debug(stan_model)

and step through to figure out which condition of

        if (!file.exists(file.rda) || (mtime.rda <- file.info(file.rda)$mtime) <
           
as.POSIXct(packageDescription("rstan")$Date) || mtime.rda >
            rstan_load_time
|| !is(obj <- readRDS(file.rda),
           
"stanmodel") || !is_sm_valid(obj) || !is.null(writeLines(obj@model_code,
            con
= tf <- tempfile())) || md5 != tools::md5sum(tf)) {
       
}
       
else return(invisible(obj))

is failing unexpectedly.

Ben
 

Jonah Sol Gabry

unread,
Apr 27, 2016, 11:13:29 AM4/27/16
to stan...@googlegroups.com
Ok I'll see if I can pin down where it's failing.
--
You received this message because you are subscribed to a topic in the Google Groups "stan development mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-dev/1yaypgs1RzY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-dev+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages