Pycuda, Issues Sending Multiple Single Variable Arguments
I have a pycuda program here that reads in an image from the command line and saves a version back with the colors inverted: import pycuda.autoinit import pycuda.driver as device f
Solution 1:
The device.In
and relatives are designed for use with objects which support the Python buffer protocols (like numpy arrays). The source of your problem is using them to transfer non-buffer objects.
Just pass your scalars with the correct numpy dtype directly to your kernel call. Don't use device.In
. The fact this worked in the original case was a complete accident
Solution 2:
Okay, so by changing the variable arguments to pointers in the kernel it fixed the code, i'm not sure how or why. Here is the modified version of the kernel;
__global__ void modify_image(int* pixelcount, int* width, unsignedchar* inputimage, unsignedchar* outputimage)
{
intid = threadIdx.x + blockIdx.x * blockDim.x;
if (id >= *pixelcount)
return;
outputimage[id] = 255 - inputimage[id];
}
The remainder of the code is unchanged. If anybody wants to explain why this is a successful fix, I would greatly appreciate it.
Post a Comment for "Pycuda, Issues Sending Multiple Single Variable Arguments"