Trouble with Using OpenCL in cmdstanr

I want to use my NVIDIA GPU with STAN and searched online on how to do so. I tried downloading clinfo but I am unable to recreate the steps in the guide.

I have installed CUDA but still seem to have problems with clinfo.

Despite not being able to work these issues out, I still tried to run the following code. I saw that I get the error

libbacktrace could not find executable to open

and so I set the following PATH in system variables
and I still get the same error after running the following.

> mod1 <- cmdstan_model("mod.stan", cpp_options = list(stan_opencl = TRUE))

This is the error I get.

Compiling Stan program...
In file included from stan/src/stan/model/model_header.hpp:18:
stan/src/stan/services/util/create_rng.hpp:35:1: internal compiler error: in gt_pch_note_object, at ggc-common.c:276
 }  // namespace stan

libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <> for instructions.

mingw32-make.exe: *** [make/program:25: stan/src/stan/model/model_header_opencl.hpp.gch] Error 1

Error: An error occured during compilation! See the message above for more information.
  • Operating System: Windows 10
  • CmdStan Version: “2.27.0”
  • R Version: 4.1.1

I have also added the following file under C:\Users\plshelpme\Documents.cmdstan\cmdstan-2.27.0\stan\lib\stan_math\lib



CC = g++

Hi, sorry for not getting to you earlier.

Just to be clear - are you able to run regular Stan models without GPU support?

Could you be more specific on where you are having problems? Can you run clinfo? Does your graphics card show as a valid OpenCL platform and device?

Best of luck with your model!

1 Like