Failed to run opencl demo on a Windows machine

Hi Stan developers,

Thanks for your wonderful work, and I feel great to start using Stan. I was trying to follow this demo using opencl Running Stan on the GPU with OpenCL • cmdstanr on a Windows machine. I have installed CUDA toolkit and driver, I have also installed Intel CPU runtime for opencl following this 14 Parallelization | CmdStan User’s Guide, OpenCL™ Runtimes for Intel® Processors. However, I got the following error when enabled stan_opencl = TRUE in cmdstan_model() function.

Compiling Stan program...
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lOpenCL
collect2.exe: error: ld returned 1 exit status

I am sure that rtools are installed and paths are set, because I could compile the model without stan_opencl = TRUE, could you please help to find out the reason? should I reinstall rtools since I did it before installing CUDA toolkit. Also, how can I find the platform and device numbers as one does clinfo -l in Linux?

Cheers,
Michelle

Hi,

for Windows you need to specify the path to OpenCL.

See here: cmdstanr/opencl.Rmd at 5f93e8e5762308d544e0c5d93da19b972626cba1 · stan-dev/cmdstanr · GitHub

We are going to add this to the demo in the very near future.

1 Like

Thanks. It’s rebuilding now. May I ask when you mentioned

run the below script and set path_to_opencl_lib to the path to the OpenCL.lib file on your system.

how do I do it? I can not find a path named OpenCL.lib under my env path list.

I got the rebuilding output like the following

mingw32-make[1]: Leaving directory 'C:/Users/michelle/Documents/.cmdstanr/cmdstan-2.28.2/stan/lib/stan_math/lib/tbb'

NOTE: Please add C:/Users/michelle/Documents/.cmdstanr/cmdstan-2.28.2/stan/lib/stan_math/lib/tbb to your PATH variable.
You may call

mingw32-make install-tbb

to automatically update your user configuration.
--- CmdStan v2.28.2 built ---

Should I just add this path to my env path, or just run mingw32-make install-tbb, or do both?

Thanks