I am trying to build a Stan model within a Docker container using Ubuntu 18.04 and PyStan 3.2.0. I installed PyStan using poetry, and can run the eight schools model with no problems.
The model itself was developed on my local machine with rstan, and compilation and sampling work fine there. But within the Docker + PyStan environment, I get the following warnings and errors which make me think it might be a compiler issue.
Building: found in cache, done.
Messages from stanc:
Warning in '/tmp/httpstan_6y_btqbz/model_kuf5ecx3.stan', line 5, column 13: Use of poisson_cdf without a vertical bar (|) between the first two arguments is deprecated.Warning: The parameter theta has no priors.
Warning: The parameter beta_shop_device has no priors.
Warning: The parameter beta_other has no priors.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/tmp/ipykernel_18/959323186.py in <module>
----> 1 posterior = stan.build(model_code, stan_data)
/opt/miniconda/lib/python3.8/site-packages/stan/model.py in build(program_code, data, random_seed)
510
511 try:
--> 512 return asyncio.run(go())
513 except KeyboardInterrupt:
514 return # type: ignore
/opt/miniconda/lib/python3.8/site-packages/nest_asyncio.py in run(future, debug)
30 loop = asyncio.get_event_loop()
31 loop.set_debug(debug)
---> 32 return loop.run_until_complete(future)
33
34 if sys.version_info >= (3, 6, 0):
/opt/miniconda/lib/python3.8/site-packages/nest_asyncio.py in run_until_complete(self, future)
68 raise RuntimeError(
69 'Event loop stopped before Future completed.')
---> 70 return f.result()
71
72 def _run_once(self):
/opt/miniconda/lib/python3.8/asyncio/futures.py in result(self)
176 self.__log_traceback = False
177 if self._exception is not None:
--> 178 raise self._exception
179 return self._result
180
/opt/miniconda/lib/python3.8/asyncio/tasks.py in __step(***failed resolving arguments***)
278 # We use the `send` method directly, because coroutines
279 # don't have `__iter__` and `__next__` methods.
--> 280 result = coro.send(None)
281 else:
282 result = coro.throw(exc)
/opt/miniconda/lib/python3.8/site-packages/stan/model.py in go()
502 resp = await client.post(f"/{model_name}/params", json={"data": data})
503 if resp.status != 200:
--> 504 raise RuntimeError(resp.json()["message"])
505 params_list = resp.json()["params"]
506 assert len({param["name"] for param in params_list}) == len(params_list)
KeyError: 'message'
The model file starts with these lines relevant to the warning above, and the parameters beta_shop_device and beta_other both have priors.
functions {
// Truncated at 1 for now
real poisson_lccdf_trunc(int y, real lambda) {
real a = 1 / (1 - exp(-lambda));
real b = poisson_cdf(y, lambda);
return(log1m(a * (b - exp(-lambda))));
}
}
I see that PyStan requires gcc >= 9.0.0 or clang >= 10.0.0. The Docker machine had gcc 6.0.0 when I first installed PyStan and ran the eight schools model. After getting the above errors though, I tried to install newer compilers: gcc 9 isn’t available in the standard repos for this edition of Ubuntu so I installed clang 10.0.0 but still no luck.
Is there a way that I can tell Stan which compiler to use when building the model? I can’t even see from the errors above which compiler it has used. Perhaps I also need to reinstall PyStan using the modern compiler?
Thank you!