Problem with java runtime or make, Matlab R2015b Windows
Hej, I am trying to run Stan through Matlab R2015R on my Windows 64bit machine. There are no white spaces in my directory paths. I am getting the following problem:
>> school
Having a problem getting stan version.
This is likely a problem with Java running out of file descriptors
Trying again. Trying again. Trying again. Trying again. Trying again. Trying again.
Giving up.
Output argument "ver" (and maybe others) not assigned during call to "StanModel/stan_version".
Error in StanModel (line 194)
ver = self.stan_version();
Error in stan (line 108)
model = StanModel();
Error in school (line 4)
fit1 = stan('file','school.stan','data',schools_dat,'iter',1000,'chains',4);
school.m
schools_dat = struct('J',8,...
'y',[28 8 -3 7 -1 1 18 12],...
'sigma',[15 10 16 11 9 11 10 18]);
fit1 = stan('file','school.stan','data',schools_dat,'iter',1000,'chains',4);
school.stan
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effect (school j)
real<lower=0> sigma[J]; // std err of effect estimate (school j)
}
parameters {
real mu;
real theta[J];
real<lower=0> tau;
}
model {
theta ~ normal(mu, tau);
y ~ normal(theta,sigma);
}
I started debugging a bit and found that this is my problem: StanModel.m
% FIXME, occasionally stanc does not return version?
Instead of fixing it, I decided to run
C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/cmdstan/bin/stanc --version
manually with this as results: stanc version 2.9.0. I ran this in cygwin (my windows command line tool of choice). I also compiled cmdstan within cygwin using their devel package.
So, with a bit of understanding your code, in StanModel.m I changed ver = self.stan_version(); to ver = [2 9 0];
Now I am running my school.m script again with the following output:
>> school
Error using processManager/start (line 362)
Java exception occurred:
java.io.IOException: Cannot run program "make" (in directory "C:\Users\HIDEME\Documents\PhD\Courses\BayesianDataAnalysis\cmdstan"): CreateProcess error=2, The system
cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 3 more
Error in processManager/set.command (line 212)
self.start();
Error in processManager (line 179)
self.command = p.Results.command;
Error in StanModel/compile (line 847)
p = processManager('id','compile',...
Error in StanModel/sampling (line 719)
self.compile();
Error in stan (line 137)
fit = model.sampling(p.Unmatched);
Error in school (line 4)
fit1 = stan('file','school.stan','data',schools_dat,'iter',1000,'chains',4);
So back to debugging.
Inside the function start(self) of processManager.m I set a breakpoint at
self(i).process = runtime.exec(self(i).command, self(i).envp, java.io.File(self(i).workingDir));
Manually extracting self(i).command, self(i).envp and java.io.File(self(i).workingDir) gave me make C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/111/ex4/school.exe, [] and C:\Users\HIDEME\Documents\PhD\Courses\BayesianDataAnalysis\cmdstan, respectively.
Back to cygwin (my windows command line tool of choice), I cd into C:\Users\HIDEME\Documents\PhD\Courses\BayesianDataAnalysis\cmdstan and run make C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/111/ex4/school.exe with the following output:
--- Linking C++ model ---
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -O3 -o C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/111/ex4/school.exe src/cmdstan/main.cpp -include C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/111/ex4/school.hpp -static-libgcc -static-libstdc++
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libstdc++.a(cow-stdexcept.o): In function `std::logic_error::logic_error(std::logic_error const&)':
/usr/src/debug/gcc-5.3.0-3/libstdc++-v3/src/c++11/cow-stdexcept.cc:44: multiple definition of `std::logic_error::logic_error(std::logic_error const&)'
/tmp/cc1PMwpv.o:main.cpp:(.text$_ZNSt11logic_errorC2ERKS_[_ZNSt11logic_errorC2ERKS_]+0x0): first defined here
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libstdc++.a(cow-stdexcept.o): In function `std::logic_error::logic_error(std::logic_error const&)':
/usr/src/debug/gcc-5.3.0-3/libstdc++-v3/src/c++11/cow-stdexcept.cc:44: multiple definition of `std::runtime_error::runtime_error(std::runtime_error const&)'
/tmp/cc1PMwpv.o:main.cpp:(.text$_ZNSt13runtime_errorC2ERKS_[_ZNSt13runtime_errorC2ERKS_]+0x0): first defined here
collect2: error: ld returned 1 exit status
makefile:72: recipe for target 'C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/111/ex4/school.exe' failed
make: *** [C:/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/111/ex4/school.exe] Error 1
I'd love to debug this. But its beyond my comprehension.. Further, I don't know whether I messed something up beforehand. Thank you for your time. Rasmus
Thanks for the detailed report. Can you verify that your CmdStan installation works from the command line (ie, outside of Matlab)?
I rebuild everything
HIDEME@DTU-1234567 /cygdrive/c/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/cmdstan
$ make build
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/ lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/ boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uniniti alized -c -O3 -o bin/cmdstan/stanc.o src/cmdstan/stanc.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/bare_type_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/bare_type_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/expression07_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/expression07_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/expression_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/expression_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/functions_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/functions_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/indexes_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/indexes_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/program_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/program_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/statement_2_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/statement_2_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/statement_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/statement_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/term_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/term_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/var_decls_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/var_decls_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/grammars/whitespace_grammar_inst.o stan_2.9.0/src/stan/lang/grammars/whitespace_grammar_inst.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/stan/lang/ast_def.o stan_2.9.0/src/stan/lang/ast_def.cpp
ar -rs bin/libstanc.a bin/stan/lang/grammars/bare_type_grammar_inst.o bin/stan/lang/grammars/expression07_grammar_inst.o bin/stan/lang/grammars/expression_grammar_inst.o bin/stan/lang/grammars/functions_grammar_inst.o bin/stan/lang/grammars/indexes_grammar_inst.o bin/stan/lang/grammars/program_grammar_inst.o bin/stan/lang/grammars/statement_2_grammar_inst.o bin/stan/lang/grammars/statement_grammar_inst.o bin/stan/lang/grammars/term_grammar_inst.o bin/stan/lang/grammars/var_decls_grammar_inst.o bin/stan/lang/grammars/whitespace_grammar_inst.o bin/stan/lang/ast_def.o
ar: creating bin/libstanc.a
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -O3 -o bin/stanc.exe bin/cmdstan/stanc.o -Lbin -lstanc
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/cmdstan/stansummary.o src/cmdstan/stansummary.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -O3 -o bin/stansummary.exe bin/cmdstan/stansummary.o -static-libgcc -static-libstdc++
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -c -O3 -o bin/cmdstan/print.o src/cmdstan/print.cpp
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -O3 -o bin/print.exe bin/cmdstan/print.o -static-libgcc -static-libstdc++
--- CmdStan v2.9.0 built ---
and then ran:
HIDEME@DTU-1234567 /cygdrive/c/Users/HIDEME/Documents/PhD/Courses/BayesianDataAnalysis/cmdstan
$ make examples/bernoulli/bernoulli.exe
--- Translating Stan model to C++ code ---
bin'\'stanc.exe examples/bernoulli/bernoulli.stan --o=examples/bernoulli/bernoulli.hpp
Model name=bernoulli_model
Input file=examples/bernoulli/bernoulli.stan
Output file=examples/bernoulli/bernoulli.hpp
--- Linking C++ model ---
g++ -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I stan_2.9.0/src -isystem stan_2.9.0/lib/stan_math_2.9.0/ -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/eigen_3.2.4 -isystem stan_2.9.0/lib/stan_math_2.9.0/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -m64 -Wno-unused-function -Wno-uninitialized -O3 -o examples/bernoulli/bernoulli.exe src/cmdstan/main.cpp -include examples/bernoulli/bernoulli.hpp -static-libgcc -static-libstdc++
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libstdc++.a(cow-stdexcept.o): In function `std::logic_error::logic_error(std::logic_error const&)':
/usr/src/debug/gcc-5.3.0-3/libstdc++-v3/src/c++11/cow-stdexcept.cc:44: multiple definition of `std::logic_error::logic_error(std::logic_error const&)'
/tmp/ccFU7ELg.o:main.cpp:(.text$_ZNSt11logic_errorC2ERKS_[_ZNSt11logic_errorC2ERKS_]+0x0): first defined here
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libstdc++.a(cow-stdexcept.o): In function `std::logic_error::logic_error(std::logic_error const&)':
/usr/src/debug/gcc-5.3.0-3/libstdc++-v3/src/c++11/cow-stdexcept.cc:44: multiple definition of `std::runtime_error::runtime_error(std::runtime_error const&)'
/tmp/ccFU7ELg.o:main.cpp:(.text$_ZNSt13runtime_errorC2ERKS_[_ZNSt13runtime_errorC2ERKS_]+0x0): first defined here
collect2: error: ld returned 1 exit status
makefile:72: recipe for target 'examples/bernoulli/bernoulli.exe' failed
make: *** [examples/bernoulli/bernoulli.exe] Error 1
I guess not... what do I have to do?
I got the same problem in my MatlabStan 2.15.1.0. Matlab version 2018b. Windows10, 64bit. Hope some suggestions.
Same issue as well, MATLAB 2019b on Mac Catalina.
ditto. MATLAB 2020b on macOS Big Sur 11.2.3