Skip to content

Commit

Permalink
Rel 9.3.0 - Details on installing cmdstan added
Browse files Browse the repository at this point in the history
  • Loading branch information
goedman committed Feb 19, 2022
1 parent b6b4fcb commit e0a359b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
86 changes: 86 additions & 0 deletions INSTALLING_CMDSTAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Installing cmdstan.

## Clone the cmdstan.git repo. Big! Takes a while, by far the longest step.

```
git clone https://github.com/stan-dev/cmdstan.git --recursive cmdstan
# or e.g.
# git clone -b v2.28.2 https://github.com/stan-dev/cmdstan.git --recursive cmdstan
```

## Customize cmdstan.

```
cd cmdstan
# Create ./make/local from ./make/local.example or copy from a previous install
# ls -lia ./make/local
#ls: ./make/local: No such file or directory
# If you want to customize the ./make/local.example file
# ls -lia ./make/local.example
# cp -R ./make/local.example ./make/local
# ls -lia ./make/local
# Now un-comment the CXX=clang++ and STAN_THREADS=true lines in ./make/local.
# Or do:
touch ./make/local
echo "CXX=clang++\nSTAN_THREADS=true" > ./make/local
# If you prefer using gcc instead of clang++ use:
# echo "STAN_THREADS=true" > ./make/local
```

## Build cmdstan.

```
# If a previous install has been compiled in this directory:
# make clean-all # or
# make -B -j9 build
make -j9 build
```

## Test cmdstan was built correctly.

```
make examples/bernoulli/bernoulli
./examples/bernoulli/bernoulli num_threads=6 sample num_chains=4 data file=examples/bernoulli/bernoulli.data.json
bin/stansummary output_*.csv
```

## For Stan.jl etc. to find cmdstan, export CMDSTAN
```
export CMDSTAN=`pwd` # Use value of `pwd` here
```

## Below an example of the `make/local` file mentioned above with the CXX and STAN_THREADS lines enabled.

```
# To use this template, make a copy from make/local.example to make/local
# and uncomment options as needed.
# Be sure to run `make clean-all` before compiling a model to make sure
# everything gets rebuilt.
# Change the C++ compiler if needed
CXX=clang++ # Only needed on macOS if clang++ is preferred.
# Enable threading
STAN_THREADS=true
# Enable the MPI backend (requires also setting (replace gcc with clang on Mac)
# STAN_MPI=true
# CXX=mpicxx
# TBB_CXX_TYPE=gcc
```
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ The StanJulia ecosystem includes 2 additional packages, StanQuap.jl (to compute

## Requirements

**Stan's cmdstan executable needs to be installed separatedly.** Please see [cmdstan installation](https://stanjulia.github.io/Stan.jl/latest/INSTALLATION/). If you plan to use C++ level threads, please read the `make/local-example` instructions and below section.
**Stan's cmdstan executable needs to be installed separatedly.** Please see [cmdstan installation](https://stanjulia.github.io/Stan.jl/latest/INSTALLATION/). If you plan to use C++ level threads, please read the `make/local-example` instructions and below section and [this file](https://github.com/StanJulia/StanSample.jl/blob/master/INSTALLING_CMDSTAN.md).


## Options for multi-threading and multi-chaining

Expand Down

0 comments on commit e0a359b

Please sign in to comment.