Stan 15.1 broken (for me) in Windows 10

173 views
Skip to first unread message

Matthew Simpson

unread,
May 4, 2017, 2:10:06 PM5/4/17
to Stan users mailing list
I recently updated my R and RStan installations in Windows 10, and it broke RStan. I was previously using R 3.3.3 and RStan 2.14.2. When I updated, suddenly R would crash when I tried to run models that ran perfectly before. I tried uninstalling all versions of R, Rtools, and all R libraries, and reinstalling from scratch, but to no avail.

To be precise, this is what I've tried installing:
R 3.4
Rtools 3.4 (most recent version, notably non-frozen)
RStan 15.1

A minimal example of the problem in in the attached .stan and .R files. Basically, R crashes when you call stan() on a previously compiled model with a vector parameter with a dimension larger than 43, but only when you call stan() for the second time on that model. Stan compiles the model find and will sample from it as long as sampling is part of the same stan() call as compilation. But if I try to sample from a previously compiled model, R crashes. Interestingly, I have some saved Stan models compiled in my previous R/Rstan install (Stan 2.14.2 in R 3.3.3 with I believe Rtools 3.3). Saved in the sense that I called > save(fit, file = "fit.RData") in R, modulo the file/object names. If I load one of them into R 3.4 and use RStan 15.1 to sample from that model, I have zero problems.

Note: when R crashes, it gives the error code 255, though occasionally it will give the code 5.

Everything seems to work perfectly in Ubuntu with a fresh install of R 3.4 and RStan 15.1, so I suspect it has something to do with Rtools and the compiler it makes available.

Other things I've tried in Windows:

1) Install RStan 15.1 in R 3.3.3 using Rtools 3.3. This caused R to crash when the first time stan() was called on the model, though notably after compilation.
2) Install RStan 15.1 in R 3.4 using Rtools 3.4 from source. This threw an error - it had trouble installing RcppEigen for some reason (I don't have the error message recorded anywhere, sorry, but I believe it complained about the c++ compiler).

So I have two questions: 1) Is there a tweak to the installation process that will make everything work? Or, failing that, 2) How do I install an old version of RStan so I can get back to work?

Thanks,
Matt
testing.R
testing.stan

Ben Goodrich

unread,
May 4, 2017, 2:25:54 PM5/4/17
to Stan users mailing list
On Thursday, May 4, 2017 at 2:10:06 PM UTC-4, Matthew Simpson wrote:
A minimal example of the problem in in the attached .stan and .R files. Basically, R crashes when you call stan() on a previously compiled model with a vector parameter with a dimension larger than 43, but only when you call stan() for the second time on that model. Stan compiles the model find and will sample from it as long as sampling is part of the same stan() call as compilation. But if I try to sample from a previously compiled model, R crashes.

That is a weird result, which does not happen to me on R for Windows 3.4.0. Try calling

fit0 <- stan("testing.stan", data = testdat, chains = 1, iter = 1)
fit   <- stan("testing.stan", data = testdat)

It should neither crash nor recompile, but who knows.

Ben

Matthew Simpson

unread,
May 4, 2017, 2:37:34 PM5/4/17
to Stan users mailing list
It does not recompile, but it does crash. Dumping the output of my R console below.

Matt

R version 3.4.0 (2017-04-21) -- "You Stupid Darkness"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> > options(chmhelp=FALSE, help_type="text")
> options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient.exe', show.error.locations=TRUE)
> library(rstan)
Loading required package: ggplot2
Stackoverflow is a great place to get help:
Loading required package: StanHeaders
rstan (Version 2.15.1, packaged: 2017-04-19 05:03:57 UTC, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
> testdat <- list(n = 44) ## everything works fine for n < 44
> fit0 <- stan("testing.stan", data = testdat, chains = 1, iter = 1) ## should be ok
fit   <- stan("testing.stan", data = testdat)
In file included from c:/Program Files/R/R-3.4.0/library/BH/include/boost/config.hpp:39:0,
                 from c:/Program Files/R/R-3.4.0/library/BH/include/boost/math/tools/config.hpp:13,
                 from c:/Program Files/R/R-3.4.0/library/StanHeaders/include/stan/math/rev/core/var.hpp:7,
                 from c:/Program Files/R/R-3.4.0/library/StanHeaders/include/stan/math/rev/core/gevv_vvv_vari.hpp:5,
                 from c:/Program Files/R/R-3.4.0/library/StanHeaders/include/stan/math/rev/core.hpp:12,
                 from c:/Program Files/R/R-3.4.0/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from c:/Program Files/R/R-3.4.0/library/StanHeaders/include/stan/math.hpp:4,
                 from c:/Program Files/R/R-3.4.0/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file2aa448a916a3.cpp:8:
c:/Program Files/R/R-3.4.0/library/BH/include/boost/config/compiler/gcc.hpp:186:0: warning: "BOOST_NO_CXX11_RVALUE_REFERENCES" redefined
 #  define BOOST_NO_CXX11_RVALUE_REFERENCES
 ^
<command-line>:0:0: note: this is the location of the previous definition

SAMPLING FOR MODEL 'testing' NOW (CHAIN 1).

Gradient evaluation took 0 seconds
1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Adjust your expectations accordingly!


WARNING: No variance estimation is
         performed for num_warmup < 20

Iteration: 1 / 1 [100%]  (Sampling)

 Elapsed Time: 0 seconds (Warm-up)
               0 seconds (Sampling)
               0 seconds (Total)

> 

SAMPLING FOR MODEL 'testing' NOW (CHAIN 1).

Gradient evaluation took 0 seconds
1000 transitions using 10 leapfrog steps per transition would take 0 seconds.
Adjust your expectations accordingly!


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

Process R exited abnormally with code 255 at Thu May  4 13:36:16 2017

Matthew Simpson

unread,
May 4, 2017, 3:50:16 PM5/4/17
to Stan users mailing list
An update: on a different machine running Windows 8.1, I tried installing R 3.4, Rtools 3.4, and RStan 15.1 from scratch, and I get the same results.

The version of Rtools I have on both machines is 3.4.0.1964 (available in c:/Rtools/VERSION.txt)

I still suspect my version of Rtools is the culprit, and since this is a non-frozen version, other people might have slightly different versions. If it's working for you and not me, it's worth checking which version you have.

Thanks,

Matt

Ben Goodrich

unread,
May 4, 2017, 4:13:57 PM5/4/17
to Stan users mailing list
On Thursday, May 4, 2017 at 3:50:16 PM UTC-4, Matthew Simpson wrote:
I still suspect my version of Rtools is the culprit, and since this is a non-frozen version, other people might have slightly different versions. If it's working for you and not me, it's worth checking which version you have.

I have 3.4.0.1962 . It may be worth trying with Rterm.exe to see if you get more of an error message when it crashes.

Ben

Matthew Simpson

unread,
May 4, 2017, 4:36:51 PM5/4/17
to Stan users mailing list
Rterm.exe gives less of an error message. I get the windows error message that always pops up (that I didn't mention before), saying R has stopped working, etc. Then closing the error pop up window closes the program. I tried Rgui too with the same results.

Matt

Ben Goodrich

unread,
May 4, 2017, 5:40:23 PM5/4/17
to Stan users mailing list
On Thursday, May 4, 2017 at 4:36:51 PM UTC-4, Matthew Simpson wrote:
Rterm.exe gives less of an error message. I get the windows error message that always pops up (that I didn't mention before), saying R has stopped working, etc. Then closing the error pop up window closes the program. I tried Rgui too with the same results.

Try installing Rcpp from source

Matthew Simpson

unread,
May 4, 2017, 6:05:39 PM5/4/17
to Stan users mailing list
After installing Rcpp from source, I still get the error, but now I get it the first time I call stan() on the model but notably after compilation. This was on the Windows 8 machine, where I hadn't tried installing RStan from source yet, so I did that and it installed successfully. Or at least without error. But I still get the error after that, again the first time I call stan() on the model but after compilation.

Thanks for the suggestions though.

Matt

Ben Goodrich

unread,
May 5, 2017, 10:59:37 AM5/5/17
to Stan users mailing list
I'm obviously guessing since I can't reproduce this and haven't heard of anyone else with a problem nearly this odd, but maybe try with -O2 in Makevars rather than -O3?

Matthew Simpson

unread,
May 5, 2017, 2:04:51 PM5/5/17
to Stan users mailing list
Yeah, I appreciate it nonetheless. When I install RStan with -O2 R crashes the first time I call stan() on the example model, though again after compilation.

I installed in the usual way and did not build from source, i.e. via install.pacakges("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)

And my Makevars file had one line:

CXXFLAGS=-O2 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function

I've emailed the maintainer of Rtools to see if I can get a different version of Rtools 3.4 to try. Hopefully he has one and hopefully that fixes it.

Ben Goodrich

unread,
May 5, 2017, 2:06:34 PM5/5/17
to Stan users mailing list
On Friday, May 5, 2017 at 2:04:51 PM UTC-4, Matthew Simpson wrote:
And my Makevars file had one line:

CXXFLAGS=-O2 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function

You could also try without the -mtune=native -march=native

Matthew Simpson

unread,
May 5, 2017, 2:23:02 PM5/5/17
to Stan users mailing list
Well right after I sent my last message I tried it with -O1 and it worked. Confirmed on both machines and also in the larger model that I was originally working with when I ran into the issue. I'll try your suggestions just to see what happens though.

Matthew Simpson

unread,
May 5, 2017, 2:27:09 PM5/5/17
to Stan users mailing list
your suggestion worked too: -O3 but without -mtune=native and without -march=native worked on both machines and also with the original model.

I'm not sure what's going on, but at least it's working now! Thanks for the help.

Matt

Ben Goodrich

unread,
May 5, 2017, 2:58:16 PM5/5/17
to Stan users mailing list
On Friday, May 5, 2017 at 2:27:09 PM UTC-4, Matthew Simpson wrote:
your suggestion worked too: -O3 but without -mtune=native and without -march=native worked on both machines and also with the original model.

I hate it when I'm right.

Reply all
Reply to author
Forward
0 new messages