1

我正在尝试复制此博客文章中的示例:

http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/

在我实现 Numba 后,我得到以下回溯:

AssertionError                            Traceback (most recent call last)
<ipython-input-4-1859e40c79ab> in <module>()
      4 pairwise_numba = autojit(pairwise_python)
      5 
----> 6 get_ipython().magic('timeit pairwise_numba(X)')
      7 

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\IPython\core\interactiveshell.py in magic(self, arg_s)
   2135         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2136         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2137         return self.run_line_magic(magic_name, magic_arg_s)
   2138 
   2139     #-------------------------------------------------------------------------

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line)
   2061                 args.append(sys._getframe(stack_depth).f_locals)
   2062             with self.builtin_trap:
-> 2063                 result = fn(*args)
   2064             return result
   2065 

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\IPython\core\magics\execution.py in timeit(self, line, cell)

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    190     # but it's overkill for just that one bit of state.
    191     def magic_deco(arg):
--> 192         call = lambda f, *a, **k: f(*a, **k)
    193 
    194         if isinstance(arg, collections.Callable):

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\IPython\core\magics\execution.py in timeit(self, line, cell)
    804             number = 1
    805             for i in range(1, 10):
--> 806                 if timer.timeit(number) >= 0.2:
    807                     break
    808                 number *= 10

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\timeit.py in timeit(self, number)
    188         gc.disable()
    189         try:
--> 190             timing = self.inner(it, self.timer)
    191         finally:
    192             if gcold:

<magic-timeit> in inner(_it, _timer)

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\numbawrapper.pyd in numba.numbawrapper._NumbaSpecializingWrapper.__call__ (numba\numbawrapper.c:3726)()

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\wrapping\compiler.py in compile_from_args(self, args, kwargs)
     66     def compile_from_args(self, args, kwargs):
     67         signature = self.resolve_argtypes(args, kwargs)
---> 68         return self.compile(signature)
     69 
     70     def compile(self, signature):

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\wrapping\compiler.py in compile(self, signature)
     81                      env=self.env, **self.flags)
     82 
---> 83         compiled_function = dec(self.py_func)
     84         return compiled_function
     85 

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\decorators.py in _jit_decorator(func)
    220         assert kwargs.get('llvm_ee') is None, "Engine should never be provided"
    221         sig, lfunc, wrapper = compile_function(
--> 222             env, func, argtys, restype=return_type, nopython=nopython, **kwargs)
    223         return numbawrapper.create_numba_wrapper(func, wrapper, sig, lfunc)
    224 

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\decorators.py in compile_function(env, func, argtypes, restype, **kwds)
    131     assert kwds.get('llvm_module') is None, kwds.get('llvm_module')
    132 
--> 133     func_env = pipeline.compile2(env, func, restype, argtypes, **kwds)
    134 
    135     function_cache.register_specialization(func_env)

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\pipeline.py in compile2(env, func, restype, argtypes, ctypes, compile_only, **kwds)
    132         pipeline = env.get_pipeline(kwds.get('pipeline_name', None))
    133         func_ast.pipeline = pipeline
--> 134         post_ast = pipeline(func_ast, env)
    135         func_signature = func_env.func_signature
    136         symtab = func_env.symtab

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\pipeline.py in __call__(self, ast, env)
    179 
    180         if self.is_composed:
--> 181             ast = self.transform(ast, env)
    182         else:
    183             try:

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\pipeline.py in transform(self, ast, env)
    600                 stage_tuple = (stage, utils.ast2tree(ast))
    601                 logger.debug(pprint.pformat(stage_tuple))
--> 602             ast = stage(ast, env)
    603         return ast
    604 

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\pipeline.py in _stage(ast, env)
    585             def _stage(ast, env):
    586                 stage_obj = getattr(env.pipeline_stages, name)
--> 587                 return _check_stage_object(stage_obj)(ast, env)
    588             _stage.__name__ = name
    589             stage = _stage

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\pipeline.py in __call__(self, ast, env)
    182         else:
    183             try:
--> 184                 ast = self.transform(ast, env)
    185             except error.NumbaError as e:
    186                 func_env = env.translation.crnt

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\pipeline.py in transform(self, ast, env)
    507                                       env.llvm_context.execution_engine,
    508                                       env.crnt.llvm_module,
--> 509                                       env.crnt.lfunc)
    510         return ast
    511 

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\numba\postpasses.py in postpass_link_math(env, ee, lmod, lfunc)
     35     linker = linking.get_linker(default_math_lib)
     36     linking.link_llvm_math_intrinsics(ee, lmod, default_math_lib,
---> 37                                       linker, replacements)
     38     return lfunc

C:\WinPython-64bit-3.3.2.1\python-3.3.2.amd64\lib\site-packages\llvmmath\linking.py in link_llvm_math_intrinsics(engine, module, library, linker, replacements)
    216             sig = ltypes.Signature(restype, argtypes)
    217             linkarg = library.get_symbol(name, sig)
--> 218             assert linkarg, (name, sig, library.symbols[name])
    219             linker.link(engine, module, library, lfunc, linkarg)
    220             del lfunc # this is dead now, don't touch

AssertionError: ('sqrt', ('double', ('double',)), {})

我对python很陌生,所以我自己无法处理。在第一次运行中,我使用的是 scipy 包 + numba 和从此处下载的依赖项:http : //www.lfd.uci.edu/~gohlke/pythonlibs/,在 winpython 上尝试了相同的操作(完全重新安装了 python),结果仍然相同. Python版本是3.3 64

4

0 回答 0