I am running cmdstanr within an mclapply loop, e.g.
mod <- cmdstan_model(stan_file='myModel.stan')
results <-do.call(rbind,mclapply(1:1000,mc.cores=4,function(i) {
...
fit <- mod$sample(data=input_data,
chains=4,
parallel_chains=4)
...
})
Stan runs fine but it creates several large files within the rtmpfile /tmp/RtmpXXX and they do not get removed, but actually accumulate as the mclapply loop progresses and take up more and more space.
What can I do? Is there a way to figure out the temporary files that rcmdstan is creating so that I can delete them after each run? Any other suggestions?