Compilation error in Cmdstanr

@jonah @rok_cesnovar

Hi all,

I had errors in installing Cmdstan, now I guess I am okay with it. Thank you @rok_cesnovar for helping me. I thought to post a new topic in order to have some help further coding. This is what I have got after installing Cmdstan 2.24.1.

set_cmdstan_path(“C:/Users/nanayaer/Documents/.cmdstanr/cmdstan-2.24.1/cmdstan-2.24.1”)
Then I could run the commands
library(cmdstanr)
cmdstan_path()
[1] “C:/Users/nanayaer/Documents/.cmdstanr/cmdstan-2.24.1/cmdstan-2.24.1”
cmdstan_version()
[1] “2.24.1”

I tried to compiling a model (from https://mc-stan.org/cmdstanr/articles/cmdstanr.html)

file <- file.path(cmdstan_path(), “examples”, “bernoulli”, “bernoulli.stan”)
mod <- cmdstan_model(file)

But, It gave an error,

Compiling Stan program…
INFO: Could not find files for the given pattern(s).
Error: An error occurred during compilation! See the message above for more information

Am I wrong here?
Please kindly help me to solve my errors

Many thanks for you all

I think your installation did not complete.

Please re-run install_cmdstan(cores = 2, overwrite = TRUE) and post the output.

Output says I am failed again.

  • Latest CmdStan release is v2.24.1
  • Installing CmdStan v2.24.1 in C:/Users/nanayaer/Documents/.cmdstanr/cmdstan-2.24.1
  • Downloading cmdstan-2.24.1.tar.gz from GitHub…
  • Removing the existing installation of CmdStan…
  • Download complete
  • Unpacking archive…
  • Building CmdStan binaries…
    INFO: Could not find files for the given pattern(s).
    cp bin/windows-stanc bin/stanc.exe
    g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.7 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.2.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -fvisibility=hidden -o bin/cmdstan/stansummary.o src/cmdstan/stansummary.cpp
    cd stan/lib/stan_math/lib/boost_1.72.0; ./bootstrap.bat gcc
    Building Boost.Build engine
    g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.7 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.2.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -fvisibility=hidden -o bin/cmdstan/print.o src/cmdstan/print.cpp

Generating Boost.Build configuration in project-config.jam for gcc…

Bootstrapping is done. To build, run:

.\b2

To adjust configuration, edit ‘project-config.jam’.
Further information:

- Command line help:
.\b2 --help
 
- Getting started guide: 
http://boost.org/more/getting_started/windows.html
 
- Boost.Build documentation:
http://www.boost.org/build/

cd stan/lib/stan_math/lib/boost_1.72.0; ./b2 address-model=64 --visibility=hidden --with-program_options cxxstd=11 variant=release link=static
Performing configuration checks

- default address-model    : 64-bit
- default architecture     : x86

Building the Boost C++ Libraries.

Component configuration:

- atomic                   : not building
- chrono                   : not building
- container                : not building
- context                  : not building
- contract                 : not building
- coroutine                : not building
- date_time                : not building
- exception                : not building
- fiber                    : not building
- filesystem               : not building
- graph                    : not building
- graph_parallel           : not building
- headers                  : not building
- iostreams                : not building
- locale                   : not building
- log                      : not building
- math                     : not building
- mpi                      : not building
- program_options          : building
- python                   : not building
- random                   : not building
- regex                    : not building
- serialization            : not building
- stacktrace               : not building
- system                   : not building
- test                     : not building
- thread                   : not building
- timer                    : not building
- type_erasure             : not building
- wave                     : not building

…patience…
…found 1072 targets…
…updating 48 targets…
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\BoostDetectToolset-1.72.0.cmake
C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\tools\boost_install\BoostDetectToolset.cmake
1 file(s) copied.
boost-install.generate-cmake-config-version- bin.v2\tools\boost_install\BoostConfigVersion.cmake
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\Boost-1.72.0\BoostConfig.cmake
C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\tools\boost_install\BoostConfig.cmake
1 file(s) copied.
boost-install.generate-cmake-config- bin.v2\libs\headers\build\stage\boost_headers-config.cmake
boost-install.generate-cmake-config-version- bin.v2\libs\headers\build\stage\boost_headers-config-version.cmake
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\Boost-1.72.0\BoostConfigVersion.cmake
bin.v2\tools\boost_install\BoostConfigVersion.cmake
1 file(s) copied.
boost-install.generate-cmake-config- bin.v2\libs\program_options\build\stage\boost_program_options-config.cmake
boost-install.generate-cmake-config-version- bin.v2\libs\program_options\build\stage\boost_program_options-config-version.cmake
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\boost_headers-1.72.0\boost_headers-config.cmake
bin.v2\libs\headers\build\stage\boost_headers-config.cmake
1 file(s) copied.
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\boost_program_options-1.72.0\boost_program_options-config.cmake
bin.v2\libs\program_options\build\stage\boost_program_options-config.cmake
1 file(s) copied.
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\boost_program_options-1.72.0\boost_program_options-config-version.cmake
bin.v2\libs\program_options\build\stage\boost_program_options-config-version.cmake
1 file(s) copied.
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\boost_headers-1.72.0\boost_headers-config-version.cmake
bin.v2\libs\headers\build\stage\boost_headers-config-version.cmake
1 file(s) copied.
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\config_file.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\options_description.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\cmdline.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\parsers.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\positional_options.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\utf8_codecvt_facet.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\convert.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\variables_map.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\winmain.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\value_semantic.o
gcc.compile.c++ bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\split.o
gcc.archive bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\libboost_program_options-mgw83-mt-x64-1_72.a
boost-install.generate-cmake-variant- bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\libboost_program_options-variant-mgw83-mt-x64-1_72-static.cmake
common.copy C:\Users\nanayaer\Documents.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\libboost_program_options-mgw83-mt-x64-1_72.a
bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\libboost_program_options-mgw83-mt-x64-1_72.a
1 file(s) copied.

type "C:\Users\nanayaer\AppData\Local\Temp\jam28705367.000" > "bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\libboost_program_options-variant-mgw83-mt-x64-1_72-static.cmake"

…failed text-action bin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden\libboost_program_options-variant-mgw83-mt-x64-1_72-static.cmake…
…skipped pC:\Users\nanayaer\Documents\.cmdstanr\cmdstan-2.24.1\stan\lib\stan_math\lib\boost_1.72.0\stage\lib\cmake\boost_program_options-1.72.0libboost_program_options-variant-mgw83-mt-x64-1_72-static.cmake for lack of <pbin.v2\libs\program_options\build\gcc-8.3.0\release\cxxstd-11-iso\link-static\threading-multi\visibility-hidden>libboost_program_options-variant-mgw83-mt-x64-1_72-static.cmake…
…failed updating 1 target…
…skipped 1 target…
…updated 46 targets…
mingw32-make.exe: *** [make/command:36: stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options*.a] Error 1
mingw32-make.exe: *** Waiting for unfinished jobs…

Warning message:
There was a problem during installation. See the error message(s) above.

Hi @rok_cesnovar,

What kind of issue is behind this error? I really don’t know how to deal with it.

Thanks

And if you now run

file <- file.path(cmdstan_path(), “examples”, “bernoulli”, “bernoulli.stan”)
mod <- cmdstan_model(file)

you get the same error?

Honestly, I have not seen this one before. Looking into it. This is related to cmdstan itself, not cmdstanr related. You are running Windows 10 right?

It’s my bad luck. :(

Yes I am running Windows 10 (2016) .
Yes, I tried to run

file <- file.path(cmdstan_path(), “examples”, “bernoulli”, “bernoulli.stan”)
mod <- cmdstan_model(file)

but… this is the error

Compiling Stan program…
|
INFO: Could not find files for the given pattern(s).

INFO: Could not find files for the given pattern(s).

ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a

ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a
/
ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a
/
ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a

C:/Users/nanayaer/Documents/.cmdstanr/cmdstan-2.24.1/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0

task.o: duplicate section .rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size arena.o: duplicate section .rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]’ has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]’ has different size
/
In file included from stan/src/stan/model/model_header.hpp:16:
stan/src/stan/services/util/create_rng.hpp:35:1: fatal error: can’t write PCH file: No space left on device
} // namespace stan
^

compilation terminated.
/
mingw32-make.exe: *** [make/program:25: stan/src/stan/model/model_header.hpp.gch] Error 1

Error: An error occured during compilation! See the message above for more information.

Oh, now I finnally see it.

" can’t write PCH file: No space left on device"

We build a precompiled header when building cmdstan. This makes compilation 50% faster but does require ~500MB of space… You seem to not have enough space left on your disk.

Can you clear some space on your disk? Otherwise there is a way to turn this compilation speedup off. But I imagine you can get that space cleaned up.

1 Like

Wow… Thanks @rok_cesnovar.
I will do it now and note here.

Extremely sorry for your time wasting by me.

Hello @rok_cesnovar,

I could increase some extra space on my disk and then run the compilation code.
It game me below output. Does it seem as correct?

 file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
 mod <- cmdstan_model(file)

Compiling Stan program…

INFO: Could not find files for the given pattern(s).
|
INFO: Could not find files for the given pattern(s).

ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a
|
ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a

ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a
/
ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a
/
C:/Users/nanayaer/Documents/.cmdstanr/cmdstan-2.24.1/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0

task.o: duplicate section .rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size arena.o: duplicate section .rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]’ has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]’ has different size

Then, I run

mod$print()

and got

data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
}
parameters {
real<lower=0,upper=1> theta;
}
model {
theta ~ beta(1,1); // uniform prior on interval 0,1
y ~ bernoulli(theta);
}

Am I correct now?

Yes, you can try to compile another model and you should see no warnings. Or recompile this model.

@rok_cesnovar

Thank you for this great support :)
I recompiled it. Then appeared,

Model executable is up to date!

Could you please explain what differences between stan and cmdstan? How does it work for user defined complex functions written in rstan (with blocks)?
Any references are highly appreciated.

Thank you again.

1 Like

There’s Stan the language and algorithms and then there are interfaces to Stan like RStan, CmdStan, PyStan, etc. CmdStanR is an alternative to RStan that uses the CmdStan interface under the hood instead of using the Rcpp package to call Stan’s C++ code from R (CmdStanPy vs PyStan is similar). All the interfaces support the same Stan code (with minor exceptions because RStan is using a slightly older version of Stan than CmdStan currently but that will be updated soon). But any Stan program that works with RStan should work with CmdStanR.

Hi @jonah,

Thank you very much for getting back to me. I could find several explanations with very few examples in this regard. Then I am trying to run my stan() code with CmdStanR.

If you have the time please look at my question below and give me some ideas.

These are the several equations in my model

D_{1,t_{0}}=\beta(t_{0})\int_{0}^{t_{0}}w(x)Q(t_{0}-x)dx
D_{k,t_{0}}=\beta(t_{k-1})\Bigg\{\sum_{i=0}^{k-2}[1-\beta(t_{i})]...[1-\beta(t_{k-2})]\int_{t_{i-1}}^{t_{i}}w(x)Q(t_{k-1}-x)dx +\int_{t_{k-2}}^{t_{k-1}}w(x)Q(t_{k-1}-x)dx \Bigg\}
I_{k,t_{0}}(t)=\sum_{i=0}^{k-1}[1-\beta(t_{i})]...[1-\beta(t_{k-1})]\int_{t_{i-1}}^{t_{i}}w(x)q(t-x)dz +\int_{t_{K-1}}^{t}w(x)q(t-x)dz, \hspace{0.5cm} \forall t \in (t_{k-1},t_{k})

This is a sample data table used in my coding,
Data Table.csv (217 Bytes)

Please see this stan file

model.stan (5.0 KB)

I am getting errors because of the integrations in my model.

Chain 1 Exception: integrate: error estimate of integral 3.53534 exceeds the given relative tolerance times norm of integral

Could you please suggest a way to solve this issue, I mean some kind of technique to simplify this complex integral issue.

THANK YOU !

I think this error is related to the integral you’re solving in your Stan program and not the CmdStanR interface itself, so can you start a new post about this? I think you’ll get a better answer that way because this looks like it’s related to the use of integrate_1d in your Stan program, and there are people on the forum who are more familiar with that than I am.

At first glance it looks like you may need to change the relative tolerance, but it might actually have more to do with the specification of the model. People like @bbbales2 know the integrate functions better than I do and can help out if you start a new topic about this.

Hi @jonah,

Thank you very much for the responses. Yes, as I am using integrate_1d in my code, that is the error in stan file.
I will start a new post.

:)

1 Like