registryopencldrivers

How to disable registered OpenCL platforms on Windows?


I am using OpenCL 2.0 on Windows. My machine has 2 platforms:

I don't want OpenCL API to return the CUDA platform at all. According to this article, opencl.dll returns the registered platforms by looking at Windows registry. However, there is no mention of which registry keys are searched for.

How can I disable a certain OpenCL driver/platform on Windows so that is not returned by the API?


Solution

  • As you mention, the OpenCL ICD loader gets the list of available OpenCL platforms from the Windows registry. To prevent an OpenCL platform from appearing to any OpenCL application running on your system, you just need to remove the corresponding value from one or both of these registry keys:

    For 32-bit machines or 64-bit apps on a 64-bit machine: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors

    For 32-bit apps on a 64-bit machine: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors

    The name of the registry value will be the full path to the .dll providing the OpenCL runtime implementation.

    This is a fairly heavy-handed approach to solving the problem, in my opinion. Most OpenCL applications provide the user with a means to manually select/override the desired OpenCL platform (e.g. via a command-line argument, environment variable, or even if GUI if applicable).