inducer / pyopencl

OpenCL integration for Python, plus shiny features
http://mathema.tician.de/software/pyopencl
Other
1.05k stars 240 forks source link

Cannot create Program from binary #542

Closed yves-surrel closed 2 years ago

yves-surrel commented 2 years ago

From the doc class pyopencl.Program(context, devices, binaries), existing binaries can be provided to create a Program. However, this simple example fails:

import os
import pyopencl as cl

# Kernel function
src = """
__kernel void test(
    __global int *a)
{
    a[get_global_id(0)] = 0;
}
"""

platforms = cl.get_platforms()

for platform in platforms:
    devices = platform.get_devices()
    for i_device, device in enumerate(devices):
        ctx = cl.Context([device])
        prg = cl.Program(ctx, src).build()
        binary, = prg.get_info(cl.program_info.BINARIES)
        # Create Program from binary
        prg1 = cl.Program(ctx, (device,), (binary,))
        try:
            print(prg1.all_kernels())
        except cl.LogicError as e:
            print(e)

The result is:

clCreateKernelsInProgram failed: INVALID_PROGRAM_EXECUTABLE

for all devices found in the platform.

MacOS 11.6.4 Big Sur, Macbook Pro. On the Windows side (BootCamp), it crashes Python.