Reputation: 1
I have attempted to search for a solution or possible cause for this but I cant find anything.
Python 3.9 / pyopencl 2022.3.1
Getting Context / Queue:
PLATFORM = cl.get_platforms()[0]
DEVICE = PLATFORM.get_devices()[0]
CTX = cl.Context([DEVICE])
QUEUE = cl.CommandQueue(CTX)
Buffer Creation:
InputBuffer = cl.Buffer(CTX, cl.mem_flags.READ_WRITE, size=inputs.nbytes)
cl.enqueue_copy(QUEUE, InputBuffer, inputs).wait()
Faulty Code:
output = np.empty(InputBuffer.size, dtype=np.float32)
cl._enqueue_read_buffer(QUEUE, InputBuffer, output)
InputBuffer is a Buffer object, with a size that can vary but with my current tests, 8.
P.S. InputBuffer is a test buffer but stores the same data as the OutputBuffer. Its just changed later in the code
What I want to happen is to store the data in the "buffer" to a numpy array named "output"
So far I have tried: Using a different dtype (np.float64), No effect Using .wait(), No effect
Currently raises this error:
cl._enqueue_read_buffer(QUEUE, InputBuffer, output)
pyopencl._cl.LogicError: clEnqueueReadBuffer failed: INVALID_VALUE
Upvotes: 0
Views: 131
Reputation: 1
The error is on this line:
output = np.empty(InputBuffer.size, dtype=np.float32)
Note that InputBuffer.size
is equal to inputs.nbytes
.
Change the line to this:
output = np.empty_like(inputs)
That should fix it.
Upvotes: 0