我已经安装了LLVM 3.2和numba的所有依赖项(Meta除外):
- LLVM 3.1 或 3.2
- llvmpy(来自 llvmpy/llvmpy 分支)
- llvmmath
- numpy(版本 1.6 或更高版本)
- Meta(来自 numba/Meta 分支(可选))
- Cython(仅构建依赖项)
- nose(用于单元测试)
- argparse(用于 pycc)
我按照本页https://github.com/llvmpy/llvmpy上的说明安装了LLVM 3.2和llvmpy 。所有其他 python 模块都是使用 pip 安装的:
sudo pip install --upgrade module_name
接下来我尝试了此页面上的 numba 示例:http://jakevdp.github.io/blog/2012/08/24/numba-vs-cython/ 。我将 pairwise_python
和 pairwise_numba
存储在名为 performance.py
的文件中。然后当我运行时
from performance import *
在 IPython 中我收到以下错误:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-4-c7c496c26b18> in <module>()
----> 1 import performance
/home/carlos/Workspace/Freestyle/Numba/performance.py in <module>()
14 D[i, j] = np.sqrt(d)
15
---> 16 @jit(arg_types=[double[:,:], double[:,:]])
17 def pairwise_numba(X, D):
18 M = X.shape[0]
/usr/local/lib/python2.7/dist-packages/numba/decorators.pyc in _jit_decorator(func)
209 argtys = restype.args
210 elif argtys is None:
--> 211 assert func.__code__.co_argcount == 0, func
212 return_type = None
213 argtys = []
AssertionError: <function pairwise_numba at 0x4b61a28>
而且我无法使用pairwise_python 或pairwise_numba。我怎样才能让它发挥作用?
系统信息
- Linux Mint 13 KDE,64 位
- 默认 gcc 编译器版本:4.8
- Python 2.7.3(使用 gcc 4.6.3 编译)
- LLVM 3.2(使用 gcc 4.8 编译)
- llvmpy 0.11.2
- llvmmath 0.1.1
- numpy 1.7.1
- cython 0.19.1
- Nose 1.3.0
- argparse 1.2.1
最佳答案
您似乎向 @jit
传递了错误的参数,请尝试使用:
@autojit
def yourfunction(...):
...
如果您提供有关函数的更多详细信息,我们可以告诉您 @jit
语句有什么问题。
关于python - 使用python模块numba时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18413668/