Pystan / httpstan "Timeout" with large model

I am having an issue with fitting a large model with pystan (v3.1.1; more information below).
It is a hierarchical model and works well when I use a subset of the data (and groups) for testing, but I get the following error when I use the full data set (and all of the groups).

Building...
-------------------------------------------------------------------------------
fit_bayesian_model_cli.py 138 <module>
app()

main.py 214 __call__
return get_command(self)(*args, **kwargs)

core.py 829 __call__
return self.main(*args, **kwargs)

core.py 782 main
rv = self.invoke(ctx)

core.py 1066 invoke
return ctx.invoke(self.callback, **ctx.params)

core.py 610 invoke
return callback(*args, **kwargs)

main.py 500 wrapper
return callback(**use_params)  # type: ignore

core.py 610 invoke
return callback(*args, **kwargs)

main.py 500 wrapper
return callback(**use_params)  # type: ignore

fit_bayesian_model_cli.py 115 fit_bayesian_model
trace = fit_model(

model_fitting_api.py 228 fit_model
stan_model = model.stan_model(data=data, random_seed=seed)

hierarchical_nb.py 172 stan_model
return stan.build(

model.py 511 build
return asyncio.run(go())

runners.py 44 run
return loop.run_until_complete(main)

base_events.py 642 run_until_complete
return future.result()

model.py 460 go
resp = await client.post(f"/{model_name}/params", json={"data": data})

common.py 50 post
async with self.session.post(f"{self.base_url}{path}", json=json) as resp:

client.py 1138 __aenter__
self._resp = await self._coro

client.py 559 _request
await resp.start(conn)

client_reqrep.py 913 start
self._continue = None

helpers.py 721 __exit__
raise asyncio.TimeoutError from None

asyncio.exceptions.TimeoutError

I am fitting the model on a Linux server that I don’t have root access to. Because of this limited access, I cannot install the latest versions of ‘httpstan’ and ‘pystan’ and currently am using v4.4.2 of ‘httpstan’ and v3.1.1 of ‘pystan’. (I can’t remember exactly, but I believe the conflict is with the version of the Linux operating system and requirements of ‘httpstan’.) I am using a conda virtual environment, but had to install ‘httpstan’ and ‘pystan’ with pip to get them to work. (Again, I am able to use Stan to sample successfully from the posterior with the smaller data set / subset of groups.) I am using Python v3.9.9 and not fitting the models in a Jupyter notebook.

I hope someone can provide some insight into this problem I am having. Thank you for any help!

Wish I could be of more help.

Looks like it’s hitting a timeout in a place that suggests the problem could be with file access or compilation.

Anaconda is not supported. Can you try creating a normal Python virtualenv? Things should work better in that.

Sorry for not following up on this problem, but I couldn’t get it to work after trying various fixes. I need to use anaconda because of the system requirements and permissions (on a shared compute cluster). I ended up focussing on using PyMC to build the model, but if I was to try again with Stan, I would probably look into directly using CmdStanPy – I think it is the currently recommend interface, but could be wrong.