【问题标题】:Python kernel dies when using numba overload使用 numba 重载时 Python 内核死机
【发布时间】:2021-09-29 22:47:00
【问题描述】:

我正在尝试通过使用 numba 的重载 (docs here) 在 numba jitted 函数中使用外部定义的函数,但是当我运行它时 Python 内核会死掉。这是我要重现的最小示例:

from numpy.polynomial.legendre import leggauss as lg  # My externally defined function
import numba as nb
from numba.extending import overload

@overload(lg)
def implimentlg(n):
   if not isinstance(n, (int, nb.types.Integer, nb.int32)):
      raise nb.errors.TypingError("must be int")

   def impli(n):
      return lg(n)
   return impli

@nb.jit(nopython=True)
def tmp():
   return lg(15)

tmp()

我猜我的问题与我在 implimentlg 函数中的输入有关,但没有堆栈跟踪,我不知所措。

【问题讨论】:

    标签: python jit numba


    【解决方案1】:

    问题是我使用 neovim 包“nvim-ipy”在 iPython 终端中运行我的 python 代码。直接使用python3 myFile.py 运行我的代码会得到堆栈跟踪。

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 2022-01-07
      • 2017-02-04
      • 2016-01-03
      • 1970-01-01
      • 2018-10-05
      • 1970-01-01
      • 2020-10-03
      • 1970-01-01
      相关资源
      最近更新 更多