无法编译简单的PyCuda OSX应用程序

时间:2014-06-11 02:26:37

标签: python macos cuda gpu pycuda

我在这里遵循了PyCuda说明:http://wiki.tiker.net/PyCuda/Installation/Mac

我正在尝试编译以下代码:

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

我收到以下错误:

> python test.py

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    """)
  File "/Library/Python/2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.9-intel.egg/pycuda/compiler.py", line 251, in __init__
    arch, code, cache_dir, include_dirs)
  File "/Library/Python/2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.9-intel.egg/pycuda/compiler.py", line 241, in compile
    return compile_plain(source, options, keep, nvcc, cache_dir)
  File "/Library/Python/2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.9-intel.egg/pycuda/compiler.py", line 132, in compile_plain
    stderr=stderr.decode("utf-8", "replace"))
pycuda.driver.CompileError: nvcc compilation of /var/folders/xr/m_rf4dp96mn2tb4yxlwcft7h0000gp/T/tmpqQcztC/kernel.cu failed
[command: nvcc --cubin -arch sm_30 -m64 -I/Library/Python/2.7/site-packages/pycuda-2013.1.1-py2.7-macosx-10.9-intel.egg/pycuda/cuda kernel.cu]
[stderr:
nvcc fatal   : Path to libdevice library not specified
]

我搜索了谷歌,发现了以下主题,但他们没有帮助解决问题; http://lists.tiker.net/pipermail/pycuda/2011-June/003244.html ......

TIA!

1 个答案:

答案 0 :(得分:1)

所以问题是我没有从nvidia控制面板安装一个小更新。之后,更新我的bash_profile就行了。嘿。