在Ubuntu上安装Pycuda

时间:2012-07-16 20:30:35

标签: python boost-python pycuda

我在安装pycuda时遇到了困难。我在Ubuntu 12.04上运行。我首先安装了Enthought python发行版(即使我已经在计算机上安装了python)。我将enthought python位置添加到我的.profile中的路径(这没有问题,从命令行输入python或ipython正确使用了enthought版本)。然后我按照http://wiki.tiker.net/PyCuda/Installation/Linux/Ubuntu的说明进行操作(跳过步骤0-1,因为我已经安装了numpy和cuda)。

一切似乎都在运行并安装得很好。但是当我尝试实际使用pycuda时,它失败了。例如,以下是我尝试运行hello_gpu.py示例时会发生的情况:

:~/Downloads/pycuda-2012.1$ python examples/hello_gpu.py 
Traceback (most recent call last):
  File "examples/hello_gpu.py", line 1, in <module>
    import pycuda.driver as drv
  File "/usr/lib/python_enthought/lib/python2.7/site-packages/pycuda-2012.1-py2.7-linux-        x86_64.egg/pycuda/driver.py", line 2, in <module>
    from pycuda._driver import *
ImportError: /usr/lib/libboost_python-py27.so.1.46.1: undefined symbol:         
PyUnicodeUCS4_FromEncodedObject

或者,当我尝试从空闲中导入pycuda包时,我得到一个不同的错误:

Python 2.7.3 |EPD 7.3-1 (64-bit)| (default, Apr 11 2012, 17:52:16) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "credits", "demo" or "enthought" for more information.
>>> import pycuda
>>> pycuda
<module 'pycuda' from 'pycuda/__init__.pyc'>
>>> import pycuda.driver as drv
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pycuda/driver.py", line 2, in <module>
    from pycuda._driver import *
ImportError: No module named _driver

我怀疑部分问题是我某处没有指定python解释器的正确路径,但我无法弄清楚这个错误发生的位置。任何建议都会受到欢迎,我的想法不合适。

1 个答案:

答案 0 :(得分:0)

此问题似乎是由同一系统上两个不同Python安装之间的冲突引起的。 OP显然通过卸载Enthough Python安装并仅使用系统Python安装来解决这个问题。根据建议here

,可能还有其他方法可以使用非系统Python安装来解决此问题

[这个答案是根据评论汇总而成,并作为社区维基条目添加,希望它能够获得投票,并从PyCUDA标签的未答复列表中删除]