我正在尝试使用其中包含numba的一些代码,该代码在Windows上可以正常运行,但在MacOS上会崩溃。
基本上我有这行
self.bruit = self.noise()
numba崩溃的地方,稍后我会提供完整的日志。
功能很简单
def noise(self,):
return self.coef * random.gauss(self.m,self.s )
我不理解的是,如果我提取出这样的函数中的
self.bruit =self.coef * random.gauss(self.m, self.s)
我一点问题都没有,一切都很好。
我不明白为什么会发生此问题。
最让我困惑的是,我有另一个脚本在做基本上相同的事情(ODE较小),它使用noise()
函数,并且运行良好。
Traceback (most recent call last):
File "/Users/yochum/Desktop/NIH/NMM_Applications/LargeScale/LargeScale_NMM_GUI.py", line 1184, in Runclicked
self.LFPs,self.tp, self.Pulses, self.PPSs = self.C.Compute_Time(T,Fs,Stim=self.List_Stim,List_ParamEvol=self.List_ParamEvol ,Pre_Post=self.Simulation_Actions_StimPosPre.isChecked())
File "/Users/yochum/Desktop/NIH/NMM_Applications/LargeScale/Cortex_Model_Wendling_TargetGains.py", line 330, in Compute_Time
self.do_steptime()
File "/Users/yochum/Desktop/NIH/NMM_Applications/LargeScale/Cortex_Model_Wendling_TargetGains.py", line 156, in do_steptime
self.pop[idx].rk4()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/jitclass/boxing.py", line 62, in wrapper
return method(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/dispatcher.py", line 344, in _compile_for_args
reraise(type(e), e, None)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/six.py", line 658, in reraise
raise value.with_traceback(tb)
numba.errors.TypingError: Failed at nopython (nopython frontend)
Failed at nopython (nopython frontend)
Internal error at <numba.typeinfer.CallConstraint object at 0x13cf6a278>:
--%<----------------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/errors.py", line 491, in new_error_context
yield
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typeinfer.py", line 421, in __call__
self.resolve(typeinfer, typevars, fnty)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typeinfer.py", line 447, in resolve
sig = typeinfer.resolve_call(fnty, pos_args, kw_args, literals=literals)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typeinfer.py", line 1161, in resolve_call
literals=literals)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typing/context.py", line 204, in resolve_function_type
return func.get_call_type_with_literals(self, args, kws, literals)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/types/functions.py", line 202, in get_call_type_with_literals
return self.get_call_type(context, args, kws)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/types/functions.py", line 196, in get_call_type
return self.template(context).apply(args, kws)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typing/templates.py", line 207, in apply
sig = generic(args, kws)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/jitclass/base.py", line 322, in generic
sig = disp_type.get_call_type(self.context, args, kws)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/types/functions.py", line 253, in get_call_type
template, pysig, args, kws = self.dispatcher.get_call_template(args, kws)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/dispatcher.py", line 273, in get_call_template
self.compile(tuple(args))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/dispatcher.py", line 618, in compile
cres = self._compiler.compile(args, return_type)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/dispatcher.py", line 83, in compile
pipeline_class=self.pipeline_class)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 871, in compile_extra
return pipeline.compile_extra(func)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 365, in compile_extra
return self._compile_bytecode()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 802, in _compile_bytecode
return self._compile_core()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 789, in _compile_core
res = pm.run(self.status)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 251, in run
raise patched_exception
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 243, in run
stage()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 676, in stage_nopython_backend
self._backend(lowerfn, objectmode=False)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 626, in _backend
lowered = lowerfn()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 613, in backend_nopython_mode
self.flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/compiler.py", line 1003, in native_lowering_stage
cfunc = targetctx.get_executable(library, fndesc, env)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/targets/cpu.py", line 166, in get_executable
baseptr = library.get_pointer_to_function(fndesc.llvm_func_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/targets/codegen.py", line 461, in get_pointer_to_function
self._ensure_finalized()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/targets/codegen.py", line 103, in _ensure_finalized
self.finalize()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/targets/codegen.py", line 228, in finalize
self._optimize_final_module()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/targets/codegen.py", line 124, in _optimize_final_module
self._final_module = remove_redundant_nrt_refct(self._final_module)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/runtime/nrtopt.py", line 169, in remove_redundant_nrt_refct
new_mod = ll.parse_assembly(newll)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/llvmlite/binding/module.py", line 26, in parse_assembly
raise RuntimeError("LLVM IR parsing error\n{0}".format(errmsg))
RuntimeError: Failed at nopython (nopython mode backend)
LLVM IR parsing error
<string>:155:12: error: use of undefined value '%_ZN26Model_Wendling_TargetGains12pop_Wendling10noise$2469EN8instance8jitclass1176pop_Wendling$237fc4d10b3d38$3cA$3afloat64$2cB$3afloat64$2cG$3afloat64$2ca$3afloat64$2cb$3afloat64$2cg$3afloat64$2cC1$3afloat64$2cC2$3afloat64$2cC3$3afloat64$2cC4$3afloat64$2cC5$3afloat64$2cC6$3afloat64$2cC7$3afloat64$2cv0$3afloat64$2ce0$3afloat64$2cr$3afloat64$2cm$3afloat64$2cs$3afloat64$2ccoef$3afloat64$2cdt$3afloat64$2cNbODEs$3aint32$2cdydx$3aarray$28float64$2c$201d$2c$20A$29$2cdydx1$3aarray$28float64$2c$201d$2c$20A$29$2cdydx2$3aarray$28float64$2c$201d$2c$20A$29$2cdydx3$3aarray$28float64$2c$201d$2c$20A$29$2cdydx4$3aarray$28float64$2c$201d$2c$20A$29$2cy$3aarray$28float64$2c$201d$2c$20A$29$2cyt$3aarray$28float64$2c$201d$2c$20A$29$2cbruit$3afloat64$2cEEGoutput$3afloat64$2cpulseOutputP$3afloat64$2cpulseOutputINGabaAs$3afloat64$2cpulseOutputINGabaAf$3afloat64$2cPPSEpyrP$3afloat64$2cPPSIgabaAf$3afloat64$2cPPSIgabaAs$3afloat64$2cExtI_Pyr_to_Pyr$3afloat64$2cExtI_Gas_to_Pyr$3afloat64$2cExtI_Gaf_to_Pyr$3afloat64$2cExtI_Pyr_to_Gas$3afloat4'
br label %"_ZN26Model_Wendling_TargetGains12pop_Wendling10noise$2469EN8instance8jitclass1176pop_Wendling$237fc4d10b3d38$3cA$3afloat64$2cB$3afloat64$2cG$3afloat64$2ca$3afloat64$2cb$3afloat64$2cg$3afloat64$2cC1$3afloat64$2cC2$3afloat64$2cC3$3afloat64$2cC4$3afloat64$2cC5$3afloat64$2cC6$3afloat64$2cC7$3afloat64$2cv0$3afloat64$2ce0$3afloat64$2cr$3afloat64$2cm$3afloat64$2cs$3afloat64$2ccoef$3afloat64$2cdt$3afloat64$2cNbODEs$3aint32$2cdydx$3aarray$28float64$2c$201d$2c$20A$29$2cdydx1$3aarray$28float64$2c$201d$2c$20A$29$2cdydx2$3aarray$28float64$2c$201d$2c$20A$29$2cdydx3$3aarray$28float64$2c$201d$2c$20A$29$2cdydx4$3aarray$28float64$2c$201d$2c$20A$29$2cy$3aarray$28float64$2c$201d$2c$20A$29$2cyt$3aarray$28float64$2c$201d$2c$20A$29$2cbruit$3afloat64$2cEEGoutput$3afloat64$2cpulseOutputP$3afloat64$2cpulseOutputINGabaAs$3afloat64$2cpulseOutputINGabaAf$3afloat64$2cPPSEpyrP$3afloat64$2cPPSIgabaAf$3afloat64$2cPPSIgabaAs$3afloat64$2cExtI_Pyr_to_Pyr$3afloat64$2cExtI_Gas_to_Pyr$3afloat64$2cExtI_Gaf_to_Pyr$3afloat64$2cExtI_Pyr_to_Gas$3afloat4"
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typeinfer.py", line 138, in propagate
constraint(typeinfer)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/typeinfer.py", line 421, in __call__
self.resolve(typeinfer, typevars, fnty)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/errors.py", line 499, in new_error_context
six.reraise(type(newerr), newerr, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numba/six.py", line 659, in reraise
raise value
numba.errors.InternalError: Failed at nopython (nopython mode backend)
LLVM IR parsing error
<string>:155:12: error: use of undefined value '%_ZN26Model_Wendling_TargetGains12pop_Wendling10noise$2469EN8instance8jitclass1176pop_Wendling$237fc4d10b3d38$3cA$3afloat64$2cB$3afloat64$2cG$3afloat64$2ca$3afloat64$2cb$3afloat64$2cg$3afloat64$2cC1$3afloat64$2cC2$3afloat64$2cC3$3afloat64$2cC4$3afloat64$2cC5$3afloat64$2cC6$3afloat64$2cC7$3afloat64$2cv0$3afloat64$2ce0$3afloat64$2cr$3afloat64$2cm$3afloat64$2cs$3afloat64$2ccoef$3afloat64$2cdt$3afloat64$2cNbODEs$3aint32$2cdydx$3aarray$28float64$2c$201d$2c$20A$29$2cdydx1$3aarray$28float64$2c$201d$2c$20A$29$2cdydx2$3aarray$28float64$2c$201d$2c$20A$29$2cdydx3$3aarray$28float64$2c$201d$2c$20A$29$2cdydx4$3aarray$28float64$2c$201d$2c$20A$29$2cy$3aarray$28float64$2c$201d$2c$20A$29$2cyt$3aarray$28float64$2c$201d$2c$20A$29$2cbruit$3afloat64$2cEEGoutput$3afloat64$2cpulseOutputP$3afloat64$2cpulseOutputINGabaAs$3afloat64$2cpulseOutputINGabaAf$3afloat64$2cPPSEpyrP$3afloat64$2cPPSIgabaAf$3afloat64$2cPPSIgabaAs$3afloat64$2cExtI_Pyr_to_Pyr$3afloat64$2cExtI_Gas_to_Pyr$3afloat64$2cExtI_Gaf_to_Pyr$3afloat64$2cExtI_Pyr_to_Gas$3afloat4'
br label %"_ZN26Model_Wendling_TargetGains12pop_Wendling10noise$2469EN8instance8jitclass1176pop_Wendling$237fc4d10b3d38$3cA$3afloat64$2cB$3afloat64$2cG$3afloat64$2ca$3afloat64$2cb$3afloat64$2cg$3afloat64$2cC1$3afloat64$2cC2$3afloat64$2cC3$3afloat64$2cC4$3afloat64$2cC5$3afloat64$2cC6$3afloat64$2cC7$3afloat64$2cv0$3afloat64$2ce0$3afloat64$2cr$3afloat64$2cm$3afloat64$2cs$3afloat64$2ccoef$3afloat64$2cdt$3afloat64$2cNbODEs$3aint32$2cdydx$3aarray$28float64$2c$201d$2c$20A$29$2cdydx1$3aarray$28float64$2c$201d$2c$20A$29$2cdydx2$3aarray$28float64$2c$201d$2c$20A$29$2cdydx3$3aarray$28float64$2c$201d$2c$20A$29$2cdydx4$3aarray$28float64$2c$201d$2c$20A$29$2cy$3aarray$28float64$2c$201d$2c$20A$29$2cyt$3aarray$28float64$2c$201d$2c$20A$29$2cbruit$3afloat64$2cEEGoutput$3afloat64$2cpulseOutputP$3afloat64$2cpulseOutputINGabaAs$3afloat64$2cpulseOutputINGabaAf$3afloat64$2cPPSEpyrP$3afloat64$2cPPSIgabaAf$3afloat64$2cPPSIgabaAs$3afloat64$2cExtI_Pyr_to_Pyr$3afloat64$2cExtI_Gas_to_Pyr$3afloat64$2cExtI_Gaf_to_Pyr$3afloat64$2cExtI_Pyr_to_Gas$3afloat4"
^
[1] During: resolving callee type: BoundFunction((<class 'numba.types.misc.ClassInstanceType'>, 'noise') for instance.jitclass.pop_Wendling#7fc4d10b3d38<A:float64,B:float64,G:float64,a:float64,b:float64,g:float64,C1:float64,C2:float64,C3:float64,C4:float64,C5:float64,C6:float64,C7:float64,v0:float64,e0:float64,r:float64,m:float64,s:float64,coef:float64,dt:float64,NbODEs:int32,dydx:array(float64, 1d, A),dydx1:array(float64, 1d, A),dydx2:array(float64, 1d, A),dydx3:array(float64, 1d, A),dydx4:array(float64, 1d, A),y:array(float64, 1d, A),yt:array(float64, 1d, A),bruit:float64,EEGoutput:float64,pulseOutputP:float64,pulseOutputINGabaAs:float64,pulseOutputINGabaAf:float64,PPSEpyrP:float64,PPSIgabaAf:float64,PPSIgabaAs:float64,ExtI_Pyr_to_Pyr:float64,ExtI_Gas_to_Pyr:float64,ExtI_Gaf_to_Pyr:float64,ExtI_Pyr_to_Gas:float64,ExtI_Gas_to_Gas:float64,ExtI_Gaf_to_Gas:float64,ExtI_Pyr_to_Gaf:float64,ExtI_Gas_to_Gaf:float64,ExtI_Gaf_to_Gaf:float64,k_P:float64,k_Gas:float64,k_Gaf:float64,Stim:float64,Pre_Post:int32>)
[2] During: typing of call at /Users/yochum/Desktop/NIH/NMM_Applications/LargeScale/Model_Wendling_TargetGains.py (161)
--%<----------------------------------------------------------------------------
File "Model_Wendling_TargetGains.py", line 161:
def rk4(self):
<source elided>
#self.bruit =self.coef * random.gauss(self.m, self.s)
self.bruit = self.noise() #p(t) est le bruit d'entree dans le modele
^
[1] During: resolving callee type: BoundFunction((<class 'numba.types.misc.ClassInstanceType'>, 'rk4') for instance.jitclass.pop_Wendling#7fc4d10b3d38<A:float64,B:float64,G:float64,a:float64,b:float64,g:float64,C1:float64,C2:float64,C3:float64,C4:float64,C5:float64,C6:float64,C7:float64,v0:float64,e0:float64,r:float64,m:float64,s:float64,coef:float64,dt:float64,NbODEs:int32,dydx:array(float64, 1d, A),dydx1:array(float64, 1d, A),dydx2:array(float64, 1d, A),dydx3:array(float64, 1d, A),dydx4:array(float64, 1d, A),y:array(float64, 1d, A),yt:array(float64, 1d, A),bruit:float64,EEGoutput:float64,pulseOutputP:float64,pulseOutputINGabaAs:float64,pulseOutputINGabaAf:float64,PPSEpyrP:float64,PPSIgabaAf:float64,PPSIgabaAs:float64,ExtI_Pyr_to_Pyr:float64,ExtI_Gas_to_Pyr:float64,ExtI_Gaf_to_Pyr:float64,ExtI_Pyr_to_Gas:float64,ExtI_Gas_to_Gas:float64,ExtI_Gaf_to_Gas:float64,ExtI_Pyr_to_Gaf:float64,ExtI_Gas_to_Gaf:float64,ExtI_Gaf_to_Gaf:float64,k_P:float64,k_Gas:float64,k_Gaf:float64,Stim:float64,Pre_Post:int32>)
[2] During: typing of call at <string> (3)
File "<string>", line 3:
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.
To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/dev/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/dev/reference/numpysupported.html
For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile
If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
答案 0 :(得分:0)
我在另一个论坛上找到了解决方案
所以添加这个
newData.val()
导入后防止错误。