cmdstan: CmdStan Bernoulli Example Compiling but Not Running
Summary:
I can successfully compile the Stan model with cmdstan located in the examples/bernoulli directory, but the model is not running.
Description:
I found a similar issue here. But I want to use stan in my computer, can’t solve with that. It worked before, which I installed following the steps from the CmdStanR. But it stopped working after I updated the cmdstan with CmdStanR to 2.29.2. I forgort the older version of the cmdstan, I installed it around Oct. So I think it should be version 2.80.0.
Reproducible Steps:
At the begaining, I have followed the steps in here. Everything went well, no error or warning was shown. After the compilation of the cmdstan, I restarted the R session. After that, I tried to run the example model from the CmdStanR, but it failed.
> library(cmdstanr)
This is cmdstanr version 0.5.0
- CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
- CmdStan path: C:/Users/alimd/Documents/.cmdstan/cmdstan-2.29.2
- CmdStan version: 2.29.2
> fit <- cmdstanr_example(chains = 1)
Compiling Stan program...
Warning: Chain 1 finished unexpectedly!
Warning message:
No chains finished successfully. Unable to retrieve the fit.
I checked the steps here. Added the tbb to the environment path. I opened cmd session in the cmdstan directory, and executed the following:
mingw32-make examples/bernoulli/bernoulli.exe
This is successful, and there’s a bernoulli.exe file under the examples/bernoulli folder. I followed the steps here try to run the sampler:
cd examples/bernoulli
bernoulli.exe sample data file=bernoulli.data.json
But nothing happened. I removed everything and followed steps here, compiled cmdstan from source. The problem is still there after trying cmdstan from 2.70.0 to 2.92.2.
I have added tbb path manually and also run mingw32-make install-tbb. But the mingw32-make install-tbb works if I add quotation marks around the path in the setx command:
setx Path "%~dp0stan\lib\stan_math\lib\tbb;%OLD_SYSTEM_PATH%"
Current Output:
No output from the following command:
cd examples/bernoulli
bernoulli.exe sample data file=bernoulli.data.json
Error from R:
> fit <- cmdstanr_example(chains = 1)
Compiling Stan program...
Warning: Chain 1 finished unexpectedly!
Warning message:
No chains finished successfully. Unable to retrieve the fit.
Expected Output:
Based on the manual here, it should start working.
Additional Information:
I am using Windows 11, Rtools 4.0, R 4.1.0.
C:\Users\alimd>g++ --version
g++ (Built by Jeroen for the R-project) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\alimd>mingw32-make --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
My environment path is here, don’t know if this has any impact.
C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.11.3471.0_x64__8wekyb3d8bbwe;
C:\Users\alimd\AppData\Roaming\ActiveState\bin;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\OpenSSH\;
C:\Program Files\SASHome\SASFoundation\9.4\ets\sasexe;
C:\Program Files\SASHome\Secure\ccme4;
C:\Program Files\SASHome\SASFoundation\9.4\core\sasexe;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\dotnet\;
C:\Program Files (x86)\PDFtk Server\bin\;
C:\Program Files\Git\cmd;
C:\Perl64\bin;
C:\Users\alimd\Documents\.cmdstan\cmdstan-2.29.2\stan\lib\stan_math\lib\tbb;
C:\rtools40\usr\bin;
C:\rtools40\mingw64\bin;
C:\Users\alimd\AppData\Local\Microsoft\WindowsApps;
C:\Program Files\R\R-4.1.0\bin;
C:\Users\alimd\AppData\Local\Programs\Python\Python39;
C:\Users\alimd\AppData\Local\Programs\Python\Python39\Scripts;
C:\Users\alimd\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\alimd\AppData\Local\Programs\MiKTeX\miktex\bin\x64\;
C:\gs;
C:\Users\alimd\AppData\Local\Pandoc\;
I believe this is hard to reproduce, but I don’t know where is the problem. I have been struggling for days now. I don’t want to reinstall my OS to solve this.
Current Version:
v2.29.2
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (10 by maintainers)
Aha, that will be the issue I believe. It seems that you have multiple copies of TBB installed, and TBB is being picked up from the wrong location for Stan. I’m not sure what else would have installed TBB, since I don’t believe it comes with Windows by default.
If you feel comfortable, the solution is most likely to move the tbb path in your
PATHvariable above the reference to System32. This may negatively impact whatever other software is using TBB/installed it in System32, so you may want to do this as part of your R scripts rather than in a global configIt works, this example is given by the cmdstanr vignette. It might be good to add quotation to the setx Path in the
install-tbb.batfile though or it will throw an error.🎉🎉🎉It worked after I copied the
tbb.dllfile under theexamples/bernoullifolder. I will try to find a way to removesystem32path within R and put my solution here. So others can see how to do deal with this. Thank you very much.