删除numba.lowering.LoweringError:内部错误
作者:互联网
我正在使用numba来加速我的代码,而没有numba可以正常工作.但是使用@jit之后,它会因以下错误而崩溃:
Traceback (most recent call last):
File "C:\work_asaaki\code\gbc_classifier_train_7.py", line 54, in <module>
gentlebooster.train(X_train, y_train, boosting_rounds)
File "C:\work_asaaki\code\gentleboost_c_class_jit_v7_nolimit.py", line 298, in train
self.g_per_round, self.g = train_function(X, y, H)
File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 152, in _compile_for_args
return self.jit(sig)
File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 143, in jit
return self.compile(sig, **kws)
File "C:\Anaconda\lib\site-packages\numba\dispatcher.py", line 250, in compile
locals=self.locals)
File "C:\Anaconda\lib\site-packages\numba\compiler.py", line 183, in compile_bytecode
flags.no_compile)
File "C:\Anaconda\lib\site-packages\numba\compiler.py", line 323, in native_lowering_stage
lower.lower()
File "C:\Anaconda\lib\site-packages\numba\lowering.py", line 219, in lower
self.lower_block(block)
File "C:\Anaconda\lib\site-packages\numba\lowering.py", line 254, in lower_block
raise LoweringError(msg, inst.loc)
numba.lowering.LoweringError: Internal error:
NotImplementedError: ('cast', <llvm.core.Instruction object at 0x000000001801D320>, slice3_type, int64)
File "gentleboost_c_class_jit_v7_nolimit.py", line 103
第103行位于下面,处于循环中:
weights = np.empty([n,m])
for curr_n in range(n):
weights[curr_n,:] = 1.0/(n) # this is line 103
其中n是我的代码上面某处已经定义的常数.
如何清除错误?发生了什么“下降”?我在64位计算机上将Anaconda 2.0.1与Numba 0.13.x和Numpy 1.8.x一起使用.
解决方法:
基于此:https://gist.github.com/cc7768/bc5b8b7b9052708f0c0a,
我想出了避免该问题的方法.我没有使用冒号:来引用任何行/列,而是将循环分成两个循环以显式引用数组每个维度中的索引:
weights = np.empty([n,m])
for curr_n in range(n):
for curr_m in range (m):
weights[curr_n,curr_m] = 1.0/(n)
在此之后,我的代码中还有其他实例使用冒号,但是它们并没有导致进一步的错误,不确定原因.
标签:numba,numba-pro,arrays,python,numpy 来源: https://codeday.me/bug/20191029/1957986.html