I've just started looking into Cuda and especially PyCuda. I'm currently using Anaconda on Windows 7. I have installed Pycuda using the Anaconda Prompt and tried the following code, which I copied directly from the PyCuda documentation web page. However I've got an CompileError. Does anyone have any suggestion?
import pycuda.autoinit
import pycuda.driver as drv
import numpy
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)
multiply_them(drv.Out(dest), drv.In(a), drv.In(b), block=(400,1,1),grid(1,1))
print(dest-a*b)
Traceback (most recent call last):
File "<ipython-input-2-06c8e60d26ae>", line 12, in <module>
""")
File "C:\Users\Moritz\Anaconda3\lib\site-packages\pycuda\compiler.py", line 291, in __init__
arch, code, cache_dir, include_dirs)
File "C:\Users\Moritz\Anaconda3\lib\site-packages\pycuda\compiler.py", line 255, in compile
return compile_plain(source, options, keep, nvcc, cache_dir, target)
File "C:\Users\Moritz\Anaconda3\lib\site-packages\pycuda\compiler.py", line 137, in compile_plain
stderr=stderr.decode("utf-8", "replace"))
CompileError: nvcc compilation of C:\Users\Moritz\AppData\Loca \Temp\tmpst8z9hvc\kernel.cu failed
Ok, solved the Problem. I've only had "Microsoft Visual Studio Express" installed, which, as it seems, does not support compiling 64bit applications. However, I've been running a 64bit Version of Anaconda on my PC. Installing Anaconda 32bit instead fixed the issue.