Setting up GPU for RStan on Windows 10

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 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!

@rok_cesnovar is there a page with this info?

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:

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


Oh I also see directions for cmdstanr there:

@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:


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.

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?

Hi, @tpfau: RStan 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.