Help with OpenCL for Windows

Hey folks, I’m hoping I can get some help from you all on compiling my model with OpenCL. This problem is, I suspect, mostly a Windows thing, and maybe not necessarily a Stan thing, but I figured I’d ask in case people here have dealt with it.

I am mostly a Linux person and don’t usually muck about with Windows, but my work laptop is Windows and thus requires some struggle-bus riding.

My cmdstan version is 2.31.0 and my R version is 4.2.1.

The issue

My linker does not seem to be able to locate the OpenCL libraries, despite them being in C:\Windows\System32\:

-a---           12/7/2019  1:08 AM         113152 onexui.dll
-a---           12/7/2019  1:08 AM           2832 onnxruntime.dll
-a---           9/21/2022  2:47 PM        2191360 OpcServices.dll
-a---           6/15/2022  4:45 AM        1467080 OpenCL.dll         # It's here!
-a---           12/7/2019  1:09 AM          75776 openfiles.exe
-a---          11/14/2022 10:36 AM        1061888 opengl32.dll
-a---            4/9/2021  6:48 AM         123984 OpenWith.exe
-a---            2/7/2022  1:56 PM         135376 Optane.dll

It is listed as available under drivers for both my processor and my GPU.

When I try to compile a model with the following code:

# Set environment variables
dgp_model = cmdstanr::cmdstan_model(
  cpp_options = list(
    stan_threads = TRUE,
    stan_opencl = TRUE

I receive the error

: cannot find -lOpenCL: No such file or directory

collect2.exe: error: ld returned 1 exit status

mingw32-make: *** [make/program:59: C:\Users\cpfiffer\AppData\Local\Temp\Rtmp6VULct\model-882c4f7b710d.exe] Error 1

Anyone got the tip here? I’m sure it’s quite simple but I don’t often develop in Windows.

Thanks everyone!

See the below section from the OpenCL cmdstanr vignette - Running Stan on the GPU with OpenCL • cmdstanr

1 Like

:facepalm: Wow I completely blew past that. Thank you!