Running the following code:
# Sample source code from the Tutorial Introduction in the documentation.
import pycuda.driver as drv
from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
const int i = threadIdx.x;
dest[i] = a[i] * b[i];
multiply_them = mod.get_function("multiply_them")
a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)
dest = numpy.zeros_like(a)
drv.Out(dest), drv.In(a), drv.In(b),
generates this error:
Traceback (most recent call last):
File "C:\Users\Nathan\workspace\PyCUDA Demo\src\main.py", line 13, in
File "C:\Python27\lib\site-packages\pycuda\compiler.py", line 238, in
self.module = module_from_buffer(cubin)
pycuda._driver.LogicError: cuModuleLoadDataEx failed: invalid image -
At this point I feel I should probably mention my set up. I'm currently
The Python 2.7 Win32 PyCUDA binary from here:
I followed the tutorial from
to get set up. However,
I'm not using Visual Studios to run the program. I'm not really sure how/why
you would use VS for python development. So I've been attempting to use PyDev
for Eclipse. This initially didn't work as nvcc couldn't find the
appropriate header files (located in the Visual Studio include directory).
So I tried editing the PATH and CUDA_INC_PATH variables to no effect. Then I
tried editing nvcc.profile which resulted in a permission denied error when
it tried to access the VS include directory. In the end I just copied the
contents of the VS include directory into Python27\include\pycuda, which
worked, but it seems messy, and like it will probably become a problem for
Anyway, if anyone has an idea on the cause of the above error or how I
should proceed with PyCuda in general, I would greatly appreciate the help.
Sorry if this has been overly verbose or broad.