# Trouble with Using OpenCL in cmdstanr

**URL:** <https://discourse.mc-stan.org/t/trouble-with-using-opencl-in-cmdstanr/24031>\
**Category:** CmdStan\
**Created:** [August 18, 2021, 11:53pm UTC](https://discourse.mc-stan.org/t/trouble-with-using-opencl-in-cmdstanr/24031 "2021-08-18T23:53:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![plshelpme](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@plshelpme](https://discourse.mc-stan.org/u/plshelpme)\
**Post date:** [August 18, 2021, 11:53pm UTC](https://discourse.mc-stan.org/t/trouble-with-using-opencl-in-cmdstanr/24031/1 "2021-08-18T23:53:08Z")

</div>

I want to use my NVIDIA GPU with STAN and searched online on how to do so. I tried downloading [clinfo](https://github.com/Oblomov/clinfo) but I am unable to recreate the steps in the [guide](http://mc-stan.org/math/opencl_support.html).

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  
_C:/Users/plshelpme/Documents/.cmdstan/cmdstan-2.27.0/stan/lib/stan\_math/lib/tbb_  
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 <https://github.com/r-windows> 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

**make**

```
STAN_OPENCL=true
OPENCL_DEVICE_ID=0
OPENCL_PLATFORM_ID=0

CC = g++
LDFLAGS_OPENCL= -L"$(CUDA_PATH)\lib\x64" -lOpenCL

```

---

<div class="post-metadata">

**Author:** ![martinmodrak](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/martinmodrak/32/133_2.png) [@martinmodrak](https://discourse.mc-stan.org/u/martinmodrak)\
**Post date:** [September 6, 2021, 7:19pm UTC](https://discourse.mc-stan.org/t/trouble-with-using-opencl-in-cmdstanr/24031/2 "2021-09-06T19:19:10Z")

</div>

Hi, sorry for not getting to you earlier.

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

> [@plshelpme](#):
>
> I tried downloading [clinfo](https://github.com/Oblomov/clinfo) but I am unable to recreate the steps in the [guide](http://mc-stan.org/math/opencl_support.html).

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!
