# Setting up GPU for RStan on Windows 10

**URL:** https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472
**Category:** Developers
**Created:** [July 9, 2020, 1:54am UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472 "2020-07-09T01:54:26Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rreareyes](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rreareyes](https://discourse.mc-stan.org/u/rreareyes)
#### Post date: [July 9, 2020, 1:54am UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/1 "2020-07-09T01:54:26Z")

</div>

Hi everyone,

I was looking on information on this and I found some posts with incomplete information or redirecting to broken links inside the wiki for rstan or github repositories. My understanding is that we need to set some flags in the `Makevars.win` to allow Stan to use OpenCL when necessary. I have installed the latest `Nvidia GPU computing toolkit` and I checked my device ID using clinfo, but I can’t figure out what are the things I need to add to my Makevars file.

Thanks for your help!

---

<div class="post-metadata">

### Author: ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)
#### Post date: [July 10, 2020, 4:04pm UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/2 "2020-07-10T16:04:43Z")

</div>

@rok_cesnovar is there a page with this info?

---

<div class="post-metadata">

### Author: ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)
#### Post date: [July 10, 2020, 6:36pm UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/3 "2020-07-10T18:36:53Z")

</div>

Unforunately not for rstan as its been lagging behind with versions and stanc3 is required for maximum GPU use.

In general the instructions are the same as for cmdstan, just place the makefile flags in the makevars files instead of make/local.

Cmdstan gpu instructions: [https://github.com/bstatcomp/stan\_gpu\_install\_docs/blob/master/install\_docs/INSTALL\_CMDSTAN.md](https://github.com/bstatcomp/stan_gpu_install_docs/blob/master/install_docs/INSTALL_CMDSTAN.md)

Will add to my todo to try out rstan gpu and create proper instructions.

---

<div class="post-metadata">

### Author: ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)
#### Post date: [July 10, 2020, 6:54pm UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/4 "2020-07-10T18:54:30Z")

</div>

Oh I also see directions for cmdstanr there: [https://github.com/bstatcomp/stan\_gpu\_install\_docs/blob/master/install\_docs/INSTALL\_CMDSTANR.md](https://github.com/bstatcomp/stan_gpu_install_docs/blob/master/install_docs/INSTALL_CMDSTANR.md)

@rreareyes cmdstanr is a new interface to Stan from R. It’s lighter weight than the regular Rstan. It’s still in a kindof prerelease form but you can get it here: [https://mc-stan.org/cmdstanr/](https://mc-stan.org/cmdstanr/)

---

<div class="post-metadata">

### Author: ![rreareyes](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rreareyes](https://discourse.mc-stan.org/u/rreareyes)
#### Post date: [July 10, 2020, 8:39pm UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/5 "2020-07-10T20:39:52Z")

</div>

Thanks @rok_cesnovar and @bbbales2 ! I’ll set them up like that, I will also give a try to cmdstanr and see how it goes.

---

<div class="post-metadata">

### Author: ![tpfau](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/tpfau/32/14565_2.png) [@tpfau](https://discourse.mc-stan.org/u/tpfau)
#### Post date: [July 1, 2022, 11:28am UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/6 "2022-07-01T11:28:56Z")

</div>

Is there any update wrt RStan and GPU usage?  
I’m bumping this because it still shows up as one of the top results when searching for RStan and GPUs, and since it is now 2 years old, maybe there is some update?

---

<div class="post-metadata">

### Author: ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)
#### Post date: [July 18, 2022, 6:43pm UTC](https://discourse.mc-stan.org/t/setting-up-gpu-for-rstan-on-windows-10/16472/7 "2022-07-18T18:43:45Z")

</div>

Hi, @tpfau: [RStan](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started) on CRAN is at 2.21. RStan on GitHub is at 2.26. Stan is at 2.30. We release quarterly.

If you don’t need log density and gradient and transform access in your code, you might consider switching to `cmdstanr`, which keeps up to date with Stan w.r.t. GPU, threading, etc.
