[R] Install OpenCL

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Jun 14 12:43:09 CEST 2022

В Tue, 14 Jun 2022 10:58:59 +0200
Quirin Stier <Quirin_Stier using gmx.de> пишет:

> Sys.env(OCL="C:/Program Files/NVIDIA GPU Computing
> Toolkit/CUDA/v11.7/include/CL")

> In file included from buffer.c:2:
> ocl.h:7:10: fatal error: CL/opencl.h: No such file or directory
>      7 | #include <CL/opencl.h>
>        |          ^~~~~~~~~~~~~

Almost there. If you download the package and read the configure.win
file, or take a look at the GitHub mirror [1], you can see that the
path it uses by default for the include files is equivalent to the
following R expression: file.path(Sys.getenv('OCL'), 'include'). On the
other hand, the code assumes that the include files are available under
file.path(include_path, 'CL', 'opencl.h').

You can probably find the file C:/Program Files/NVIDIA GPU Computing
Toolkit/CUDA/v11.7/include/CL/opencl.h, so the proper path to set the
OCL variable to is "C:/Program Files/NVIDIA GPU Computing
Toolkit/CUDA/v11.7", without the "include/CL" at the end.

The configure script also assumes that there are library files under
file.path(Sys.getenv('OCL'), 'lib', architecture, 'OpenCL.lib'). If
that's not correct, you have to find them and set the OCL32LIB or
OCL64LIB environment variable to the correct path.

> How can I make sure, that the OpenCL DLLs are available via the
> %PATH%?

The expression strsplit(Sys.getenv('PATH'), ';')[[1]] will return a
vector containing paths to directories. One of them must contain the
OpenCL.dll file in order for everything to work.

Best regards,

[1] https://github.com/cran/OpenCL/blob/master/configure.win

More information about the R-help mailing list