我刚开始研究Cuda,尤其是PyCuda。我目前在Windows 7上使用Anaconda。我已经使用Anaconda Prompt安装了Pycuda并尝试了以下代码,我直接从PyCuda文档网页中复制了该代码。但是我有一个CompileError。有没有人有任何建议?
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
答案 0 :(得分:1)
好的,解决了问题。我只安装了“Microsoft Visual Studio Express”,它似乎不支持编译64位应用程序。但是,我一直在我的电脑上运行64位版本的Anaconda。安装Anaconda 32bit代替修复了这个问题。