cmdstanr icon indicating copy to clipboard operation
cmdstanr copied to clipboard

Building a model needs write access to cmdstan installation

Open weshinsley opened this issue 1 month ago • 15 comments

Describe the bug Not sure if this is an issue with cmdstanr, or cmdstan - and is something of a design problem, rather than a bug per se.

When we run

mod <- cmdstanr::cmdstan_model('code.stan', dir = path)

These two files (and perhaps others) get modified within the cmdstan installation :- cmdstan-2.35.0\src\cmdstan\main.o cmdstan-2.35.0\stan\lib\stan_math\make\ucrt

Therefore, this can only work if users have write-access to the cmdstan installation - something we need to avoid. See below.

To Reproduce Run any stan model - we used the usual one in the start-up documentation, and put it in code.stan, and then...

path <- tempfile()
dir.create(path)
mod <- cmdstanr::cmdstan_model('code.stan', dir = path)

The above two files get modified, and their date will be changed.

Expected behavior We should not have to grant users write-access to the cmdstan installation for them to run a model.

Operating system Windows 10

CmdStanR version number 8.0.1

Additional context We are running Stan in an HPC cluster context, and the issue cause us two problems:-

  1. It requires all users to have write-access to the installation of cmdstan, otherwise they get an access denied error writing the ucrt file and their job fails.

  2. Further, there are possibilities that multiple users, or even the same user might run multiple Stan jobs on the same node at the same time, which will conflict with each other if a shared cmdstan install folder is used for read/writing as part of the process.

We definitely do not want to install a new separate private cmdstan installation for every cluster job, and it's surprising to us that running a model makes actual file changes within the cmdstan installation folders. Is there a way of ensuring this happens elsewhere? We had hoped providing a dir argument would allow this.

weshinsley avatar Jun 12 '24 20:06 weshinsley