Hello all! I am running the cmdstanpy
example for within chain parallelization using reduce_sum
.
I am doing so as a base case to show the error I am getting for a bespoke model I am building.
In short:
If I run
import cmdstanpy
import pprint
cmdstanpy.install_cmdstan()
from cmdstanpy import CmdStanModel
redcard_model = CmdStanModel(
stan_file='redcard_reduce_sum.stan',
# cpp_options={'STAN_THREADS': 'TRUE'},
force_compile=True,
)
pprint.pprint(redcard_model.exe_info())
The output produced is:
{'STAN_CPP_OPTIMS': 'false',
'STAN_MPI': 'false',
'STAN_NO_RANGE_CHECKS': 'false',
'STAN_OPENCL': 'false',
'STAN_THREADS': 'false',
'stan_version_major': '2',
'stan_version_minor': '33',
'stan_version_patch': '0'}
which is expected. However, when I run
redcard_model = CmdStanModel(
stan_file='redcard_reduce_sum.stan',
cpp_options={'STAN_THREADS': 'TRUE'},
force_compile=True,
)
pprint.pprint(redcard_model.exe_info())
i.e. try to compile with stan_threads=true
, I get:
{}
as the output.
This manifests when I try to sample because, in the former case, I run 4 chains successfully, but in the latter case, I produce:
(cmdstanpy) 11:50:04 ~/dev/eligere/eligere/models/stan main $ python compute_stan_rs.py
CmdStan install directory: /Users/daniel.marthaler/.cmdstan
CmdStan version 2.33.1 already installed
Test model compilation
11:50:08 - cmdstanpy - INFO - compiling stan file /Users/daniel.marthaler/dev/eligere/eligere/models/stan/redcard_reduce_sum.stan to exe file /Users/daniel.marthaler/dev/eligere/eligere/models/stan/redcard_reduce_sum
11:50:12 - cmdstanpy - INFO - compiled model executable: /Users/daniel.marthaler/dev/eligere/eligere/models/stan/redcard_reduce_sum
{}
11:50:13 - cmdstanpy - INFO - CmdStan start processing
chain 1 |ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 00:00 Sampling completed
chain 2 |ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 00:00 Sampling completed
chain 3 |ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 00:00 Sampling completed
chain 4 |ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 00:00 Sampling completed
11:50:13 - cmdstanpy - INFO - CmdStan done processing.
Traceback (most recent call last):
File "/Users/daniel.marthaler/dev/eligere/eligere/models/stan/compute_stan_rs.py", line 34, in <module>
redcard_fit = redcard_model.sample(data=stan_data, threads_per_chain=4)
File "/Users/daniel.marthaler/.pyenv/versions/cmdstanpy/lib/python3.9/site-packages/cmdstanpy/model.py", line 1173, in sample
raise RuntimeError(msg)
RuntimeError: Error during sampling:
Command and output files:
RunSet: chains=4, chain_ids=[1, 2, 3, 4], num_processes=4
cmd (chain 1):
['/Users/daniel.marthaler/dev/eligere/eligere/models/stan/redcard_reduce_sum', 'id=1', 'random', 'seed=59043', 'data', 'file=/var/folders/rk/49593z6j4xx_hxmgmkhxh50w0000gq/T/tmpot9pytf4/gmhbohve.json', 'output', 'file=/var/folders/rk/49593z6j4xx_hxmgmkhxh50w0000gq/T/tmpot9pytf4/redcard_reduce_sumdaeecrj7/redcard_reduce_sum-20231220115013_1.csv', 'method=sample', 'algorithm=hmc', 'adapt', 'engaged=1']
retcodes=[-1, -1, -1, -1]
per-chain output files (showing chain 1 only):
csv_file:
/var/folders/rk/49593z6j4xx_hxmgmkhxh50w0000gq/T/tmpot9pytf4/redcard_reduce_sumdaeecrj7/redcard_reduce_sum-20231220115013_1.csv
console_msgs (if any):
/var/folders/rk/49593z6j4xx_hxmgmkhxh50w0000gq/T/tmpot9pytf4/redcard_reduce_sumdaeecrj7/redcard_reduce_sum-20231220115013_0-stdout.txt
Consider re-running with show_console=True if the above output is unclear!
(cmdstanpy) 11:50:13 ~/dev/eligere/eligere/models/stan main
which seems to imply that no executable was produced (and none exists in the directory).
Any thoughts?
This is an Apple Macbook Pro running an M1 Max on Sonoma 14.1.2