stan-dev / cmdstan Goto Github PK
View Code? Open in Web Editor NEWCmdStan, the command line interface to Stan
Home Page: https://mc-stan.org/users/interfaces/cmdstan
License: BSD 3-Clause "New" or "Revised" License
CmdStan, the command line interface to Stan
Home Page: https://mc-stan.org/users/interfaces/cmdstan
License: BSD 3-Clause "New" or "Revised" License
Presumably related to #27 -- make doesn't pick up any changes to dependent headers, requiring a user to delete any existing compiled executable before recompiling. I'm guessing that the makefile doesn't look into the Stan submodule somehow, although the best I can figure is that the dependencies are set in Line 108 of the makefile which should look into the submodule.
(original issue: stan-dev/stan#664)
from @tmalsburg:
The name print
is already taken by other Unix tools. Installing print
on Unix-like systems may therefore lead to conflicts. Apart from that, print
is not very informative as a name. The issue came up in #630 and I proposed to rename print
to stansummary
(reminiscent of R's summary function which does something similar for mixed models). @bob-carpenter proposed mcmcprint
and stanprint
. I like the use of stan
as a prefix for all stan-binaries because that is informative and it reduces the probability of naming conflicts with other software packages.
Changing the name would probably require changes in some other places as well: documentation, other software that builds on stan (stan-mode.el for example), etc. Not at least, the users have to relearn the command. Nevertheless, it might make sense to change it.
CmdStan needs to be updated.
Reported by @goedman on stan-dev on 6/14/2014:
I noticed below warning messages. The file is clearly available, but 1 level deeper (.../cmdstan/stan/src/stan/version.hpp).
Might just be temporarily, while the separation of stan and cmdstan is in progress.
...
From https://github.com/stan-dev/cmdstan
* branch develop -> FETCH_HEAD
Already up-to-date.
Robs-15inch-2:cmdstan rob$ make stan-update
grep: /Users/rob/Projects/Stan/cmdstan/src/stan/version.hpp: No such file or directory
grep: /Users/rob/Projects/Stan/cmdstan/src/stan/version.hpp: No such file or directory
grep: /Users/rob/Projects/Stan/cmdstan/src/stan/version.hpp: No such file or directory
git submodule init
git submodule update
Robs-15inch-2:cmdstan rob$
Additional relevant info:
I get the 3 messages every time I compile a model, not just when I update/compile CmdStan.
The issue seems to be that the path is missing the extra /stan/ element in the grep path.
But if it is just me, it is not a big deal.
And, yes, it looks like that's the issue.
Comply with stan-dev/stan#942
Hi - just tried building from current master (which I believe matches v2.4.0 - git commit 3ba4dcc). I'm on Ubuntu Trusty 14.04.1, with gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2.
These two compiles seemed to complete successfully:
make bin/libstanc.a
make bin/libstan.a
but then when I run
make src/models/basic_estimators/bernoulli
I get
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -pipe -DEIGEN_NO_DEBUG -Wno-unused-local-typedefs -lpthread -O0 -o test/test-models/stanc src/test/test-models/stanc.cpp -Lbin -lstanc
--- Translating Stan model to C++ code ---
test/test-models/stanc src/models/basic_estimators/bernoulli.stan --o=src/models/basic_estimators/bernoulli.cpp
Model name=bernoulli_model
Input file=src/models/basic_estimators/bernoulli.stan
Output file=src/models/basic_estimators/bernoulli.cpp
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -pipe -DEIGEN_NO_DEBUG -Wno-unused-local-typedefs -c -O3 -o src/models/basic_estimators/bernoulli.o src/models/basic_estimators/bernoulli.cpp
In file included from src/stan/agrad/rev.hpp:4:0,
from src/stan/model/model_header.hpp:16,
from src/models/basic_estimators/bernoulli.cpp:3:
src/stan/agrad/rev/var_stack.hpp:49:17: warning: ‘void stan::agrad::free_memory()’ defined but not used [-Wunused-function]
static void free_memory() {
^
--- Linking C++ model ---
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -pipe -DEIGEN_NO_DEBUG -Wno-unused-local-typedefs -lpthread -O3 -o src/models/basic_estimators/bernoulli src/models/basic_estimators/bernoulli.o -Lbin -lstan
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [src/models/basic_estimators/bernoulli] Error 1
Also, make bin/stanc
results in make: *** No rule to make target 'bin/stanc'. Stop.
So does make bin/print
.
I'm following the instructions in "cmdstan-guide-2.4.0.pdf". I wonder if the doc is wrong or the code is wrong...?
Running the compiled bernoulli model for help on arguments yield the following:
./bernoulli
Usage: ./bernoulli <subarg1_1> ... <subarg1_m> ... <arg_n> <subarg_n_1> ... <subarg_n_m>
Begin by selecting amongst the following inference methods and diagnostics,
sample Bayesian inference with Markov Chain Monte Carlo
optimize Point estimation
diagnose Model diagnostics
Or see help information with
help Prints help
help-all Prints entire argument tree
Additional configuration available by specifying
id Unique process identifier
data Input data options
init Initialization method: "x" initializes randomly bewteen [-x, x], "0" initializes to 0, anything else identifies a file of values
random Random number configuration
output File output options
See ./bernoulli [ help | help-all ] for details on individual arguments.
Failed to parse arguments, terminating Stan
However, the actual argument names for e.g. data and output seem to be "data file" and "output file"? E.g.: ./bernoulli sample data file=bernoulli.data.R output file=tst.csv
Remove.
stan-dev/stan#640 updates the error messages. The doc needs to change to reflect this change.
Currently failing builds due to stan_csv_reader having an additional argument.
From Andria Dawson on stan-users:
When I use the flag random seed=4294967295, I do not get the same behavior each time (whereas I do for the other seeds I get/try). When this seed is used, I see a different seed number in my csv output file as well. I flukily noticed this using one of my models, so tried with the birats models posted in the Stan examples list (see: https://github.com/stan-dev/stan/tree/master/src/models/bugs_examples/vol2/birats) but still get this strange behavior.
Is there something I am doing incorrectly that would make a single seed not work when others seem to?
I am using CmdStan 2.1.0
To see this using birats, I can run:
./birats.exe sample num_warmup=20 num_samples=10 save_warmup=1 data file=birats.dump random seed=4294967295 output file=birats.csv
I (Bob) believe the problem may be due to the fact that the given seed overflows a signed int (but not an unsigned int). We should read in a long and check that it'll fit into an int and flag it if it doesn't. No idea why the behavior would change from run to run.
[moved from stan-dev/stan#486]
Reported by Bob:
From Marcus (and me informally):
It would be great if we could run bin/print on just a CSV file of samples. That would let us monitor as we go on the CSV file. For online evaluation, it'd be very nice if we could ignore an incomplete last line.
It'd be even nicer if we had something that could connect to tail or something and calculate as we go, rather than having to recalculate bin/print. Then we could have live monitors like BUGS did
Update make target
From Michael:
Right now the parser turns example.stan into example.cpp, even though the generated C++ no longer includes a main function. It would be more consistent to have the parser generate a .hpp file.
A bunch of the tests that use parsed models will have to be updated.
Jiqiang and Andrew are going to update this:
https://github.com/stan-dev/rstan/wiki/RStan-Mac-OS-X-Prerequisite-Installation-Instructions
at which point we can just copy it into the CmdStan manual.
Current Stan develop branch isn't compatible.
(original issue: stan-dev/stan#398)
Bob writes:
We should print out informative answers for arguments of the wrong types in the command. Here's the current behavior:
~/temp2$ ./sd sample adapt engaged=4
Exception: bad lexical cast: source type value could not be interpreted as target
Diagnostic information:
Throw location unknown (consider using BOOST_THROW_EXCEPTION)
Dynamic exception type: N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_16bad_lexical_castEEEEE
std::exception::what: bad lexical cast: source type value could not be interpreted as target
What should be happening is that we detect that 4 is not a valid value for engaged, which only takes boolean values, and we should report that.
Update.
for sampling, optimization, etc.
Some of the CmdStan integration tests are out of synch.
Example:
./binormal sample random seed=4294967295
...
random
seed = 4294967295 (Default)
...
I'm not sure why it's just this argument. I've tried other values and it doesn't have this behavior.
Since the Command Stan guide was written, the example-models have been moved into their own repo. The guide references these models throughout - update all sections so that they are consistent with current repo organization.
Right now, if the user provides a file that doesn't exist, they get an error message that one of the variables in the model can't be found (init or data, depending on usage).
What should happen is that we should test that the file exists and return a meaningful message if it doesn't.
I don't know whether this is something that's going to get sorted out automatically in the new command config infrastructure or not.
(I also filed the same issue on RStan.)
Suppose I have a model compiled with the executable called foo
. After running it, I have output.csv, which has the following tails
$ tail -n 15 output.csv
-0.0448711,0.989694,1.04541,2,3,0,-0.29957,0.155283
-0.306522,0.91375,1.04541,2,3,0,0.782971,0.752996
-0.367464,0.985952,1.04541,1,1,0,0.857279,-0.0714063
-0.795205,0.968491,1.04541,2,3,0,1.26111,-1.00386
-0.387185,1,1.04541,1,1,0,0.879983,0.233558
# Elapsed Time: 0.009149 seconds (Warm-up)
# 0.016632 seconds (Sampling)
# 0.025781 seconds (Total)
# Elapsed Time: 0.009149 seconds (Warm-up)
# 0.016632 seconds (Sampling)
# 0.025781 seconds (Total)
This is fixes the CmdStan side of stan-dev/stan#726.
Reported by @ksvanhorn on stan-dev/stan#572
For example, modifying src/stan/mcmc/chains.hpp and then running make bin/print does not cause bin/print to be remade, even though it includes chains.hpp.
CmdStan needs its own startup guide / manual.
Add "-DEIGEN_NO_DEBUG" to compiler flags.
the model tests - basic distributions, estimators, bug_examples, etc - are being tested via cmd stan.
these tests need to be reworked - we should remove them for the time being, since they are too brittle to be useful.
Currently, it's bombing Jenkins by not automatically merging.
This is causing accidental commits of local files.
Rob Goedman reports on stan-users:
I noticed below warning messages. The file is clearly available, but 1 level deeper
( .../cmdstan/stan/src/stan/version.hpp).
From https://github.com/stan-dev/cmdstan
* branch develop -> FETCH_HEAD
Already up-to-date.
$ make stan-update
grep: /Users/rob/Projects/Stan/cmdstan/src/stan/version.hpp: No such file or directory
grep: /Users/rob/Projects/Stan/cmdstan/src/stan/version.hpp: No such file or directory
grep: /Users/rob/Projects/Stan/cmdstan/src/stan/version.hpp: No such file or directory
git submodule init
git submodule update
Matt Spencer's code (submitted to stan-users) either:
when running like:
> ./coralss7 data file=coralss7.data.R method=diagnose
It gets to printing TEST GRADIENT MODE
then dies.
Sebastian Weber suggested this for RStan, but it would be good to have in Stan, too. See RStan issue 38.
Boost has compression wrappers (like Java's) for streams. For instance, the bzip2 that Sebastian suggested is documented here:
http://www.boost.org/doc/libs/1_55_0/libs/iostreams/doc/classes/bzip2.html
We should be able to call make from anywhere by specifying a -f flag to the makefile in the cmdstan directory.
@mitzimorris has already gotten most of this done, but it looks like there was a snag towards the end. I'll try to get it fixed.
Standards, standards, standards.
Jarrett Barber on stan-users reported:
Hi All,
I built cmdstan 2.4.0 on Mac OS X 10.9.4 today seemingly without a hitch (as described in cmdstan-guide-2.4.0.pdf Appdendix B.7.). As a quick check to see if things are working, I tried to compile the bernoulli file as described in Section 2.4 of the guide. But, a symbol is not found; see error below. Note that my installation of cmdstan 2.1.0 still works fine. It appears that some of the directory structure of the Stan distribution has changed since 2.1.0. Perhaps the makefile needs updated flag variables to point in the right location of libraries? Just a guess. Anyway, your help is appreciated.
Best,
Jarrett
bash-3.2$ pwd
/Applications/cmdstan/stan
bash-3.2$ make src/models/basic_estimators/bernoulli
--- Linking C++ model ---
g++ -I src -isystem lib/eigen_3.2.0 -isystem lib/boost_1.54.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -pipe -DEIGEN_NO_DEBUG -Wno-unused-function -ftemplate-depth-256 -O3 -o src/models/basic_estimators/bernoulli src/models/basic_estimators/bernoulli.o -Lbin -lstan
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [src/models/basic_estimators/bernoulli] Error 1
bash-3.2$
Chop down the library size in CmdStan for releases the same way it's done in RStan (and presumably PyStan).
I think C++ Stan should keep all of the libs in its repo to make it easy to develop against.
We should have at least one simple model accessible from CmdStan.
algo=fixed_param
is specified without also specifying user-defined initsBill Harris pointed out some issues on stan-users:
src/models/basic_estimators
and we need to use the path where they actually are (I think stan/src...
)cmdstan
and cmdstan/stan
have makefilescmdstan/THIS_FILE_IS_IN_CMDSTAN_HOME
More from Bill Harris:
Still more:
The Cygwin instructions come at the end of section B.4. Does "At this point the instructions given for installing Rstan finally worked" imply one should return to the start of B.4 (Windows installation) or to B.3 (Linux installation)? The former seems to imply that Rtools is necessary, and the latter seems to suggest that the Cygwin tools may suffice.
Jiqiang and Andrew are going to update this:
https://github.com/stan-dev/rstan/wiki/RStan-Mac-OS-X-Prerequisite-Installation-Instructions
at which point we can just copy it into the CmdStan manual.
This is in a test.
This is for Jenkins. The account doesn't have config automatically set up and it fails to merge pull requests properly.
See description.
Originally reported by @ksvanhorn in stan-dev/stan#204.
Example model:
data {
int y;
}
parameters {
real<lower=0,upper=1> theta;
}
model {
}
Example data 1:
y <- -138109526142584496
Example data 2:
y <- 1234567890123456789
Running:
./issue data file=issue.data.R sample
results in:
...
Exception: variable does not exist; processing stage=data initialization; variable name=y; base type=int
Diagnostic information:
Dynamic exception type: St13runtime_error
std::exception::what: variable does not exist; processing stage=data initialization; variable name=y; base type=int
remove libstan.a
Create a new version based on Stan v2.4.0.
Update Stan to v2.5.0 and get ready for a release.
From ksvanhorn:
Often I want to process the results of the print command from R or via some other automated process. This is made more convenient if I can get the results in CSV format.
I've already written code to do this, and will be creating a feature branch with my mods.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.