Error in dyn.load(libLFile)

I am running my stan model in R, and get the following error message:

Error in dyn.load(libLFile) :
unable to load shared object ‘/tmp/Rtmpm5MO6g/file4f52500901ce.so’:
`maximal number of DLLs reached…

What does this mean? new to stan, but once I compile the model correct, any error afterwards become a blackbox for me. Any guidance on how I can figure out what the issue is step-by-step?

Thanks!

Hi @Lei_Hua are you still running into this problem? If so are you using the stan() function in rstan to run your model or are you using the combination of stan_model() and sampling()?

I used to just call stan(), not to avoid compiling every time for the simulation I am running, I separated it into stan_model() and sampling(). I haven’t seen the error message so far. Is this what is causing the issue? Thanks!

I think so. Do you have calls to stan() in a loop? If so I think that’s the cause of this

https://developer.r-project.org/Blog/public/2018/03/23/maximum-number-of-dlls/

Compiling once with stan_model() outside the loop and then using sampling() repeatedly inside the loop seems to get around the problem when I’ve seen it reported in the past.

Alternatively, I don’t think our newer R interface CmdStanR has this problem so you could try that. But stan_model() + sampling() with RStan should also be fine.

Got it. Thanks!