How to install stanc3 memory leak fix for cmdstanr?

The current release of Stan seems to be affected by a memory leak in OpenCL code. I need to build the current dev version of stanc3 and link my cmdstanr package to use the latest dev stanc3 version where the bug is fixed. Could anyone direct me on how to do this? install_cmdstan(overwrite = TRUE) downloads the latest release, but I can’t specify commit hash or anything else to build from HEAD instead.

I guess I need to build it manually using this guide? 1 CmdStan Installation | CmdStan User’s Guide But how can I make sure that building cmdstan will build the correct stanc3 version?

UPDATE. Looking at submodules of cmdstan, it seems to be using stan and not stanc3, if I am not mistaken. In this case, the same bug affects me, but in a different repo.

In order to do that you need to clone cmdstan. A cloned cmdstan will by default always use the nightly build of stanc3 (if you dont manually specify otherwise).

So run

git clone --recursive
make build -j4

and then point to that location in cmdstanr.

Sidenote: A release candidate for the next version of CmdStan that will include this fix will be available in a week or so.


Thanks, I will try that.

1 Like

This have worked. For anyone wondering on how to point cmdstanr to a custom build location: use set_cmdstan_path function.

@rok_cesnovar thanks a lot for such timely response!