# Speed up the Rstan run

**URL:** <https://discourse.mc-stan.org/t/speed-up-the-rstan-run/10799>\
**Category:** RStan\
**Created:** [September 4, 2019, 5:43pm UTC](https://discourse.mc-stan.org/t/speed-up-the-rstan-run/10799 "2019-09-04T17:43:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chwzhang09](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@chwzhang09](https://discourse.mc-stan.org/u/chwzhang09)\
**Post date:** [September 4, 2019, 5:43pm UTC](https://discourse.mc-stan.org/t/speed-up-the-rstan-run/10799/1 "2019-09-04T17:43:58Z")

</div>

Hi,

I submitted my Rstan code to remote server which has multple cores and larger RAM. I have also specific the options:  
options(mc.cores = parallel::detectCores())

posterior\_compriror \<- stan(…, chains= 4, cores = 20)

However, it does not work, the speed at remote server is quite similar to that running at my own laptop.

Could you please give me some inputs?

Chuanwu

---

<div class="post-metadata">

**Author:** ![mcol](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mcol/32/5598_2.png) [@mcol](https://discourse.mc-stan.org/u/mcol)\
**Post date:** [September 4, 2019, 7:01pm UTC](https://discourse.mc-stan.org/t/speed-up-the-rstan-run/10799/2 "2019-09-04T19:01:37Z")

</div>

Rstan parallelizes over the chains, so even if you add cores, it won’t use more than 4. You could run more chains for fewer iterations, if that doesn’t cause you convergence problems.

Besides that, as far as I know currently you can exploit better parallelism only through `map_rect`: for that, you could start from [https://github.com/rmcelreath/cmdstan\_map\_rect\_tutorial](https://github.com/rmcelreath/cmdstan_map_rect_tutorial).
