You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the great tools! I was looking at this stack overflow discussion where you posted an example of using NumbaMinpack for curve fitting.
I was wondering if NumbaMinpack (and this general approach you showed in that thread -- and copied below) can be made to work with Numba's cuda functionality. Do you know if that's possible/straightforward?
fromNumbaQuadpackimportquadpack_sig, dqagsfromNumbaMinpackimportminpack_sig, lmdifimportnumpyasnpimportnumbaasnbimporttimeitnp.random.seed(0)
x=np.linspace(0,2*np.pi,100)
y=np.sin(x)+np.random.rand(100)
@nb.jitdeffitfunction(x, A, B):
returnA*np.sin(B*x)
@nb.cfunc(minpack_sig)deffitfunction_optimize(u_, fvec, args_):
u=nb.carray(u_,(2,))
args=nb.carray(args_,(200,))
A, B=ux=args[:100]
y=args[100:]
foriinrange(100):
fvec[i] =fitfunction(x[i], A, B) -y[i]
optimize_ptr=fitfunction_optimize.address@nb.cfunc(quadpack_sig)deffitfunction_integrate(x, data):
A=data[0]
B=data[1]
returnfitfunction(x, A, B)
integrate_ptr=fitfunction_integrate.address@nb.njitdeffast_function():
try:
neqs=100u_init=np.array([2.0,.8],np.float64)
args=np.append(x,y)
fitparam, fvec, success, info=lmdif(optimize_ptr , u_init, neqs, args)
ifnotsuccess:
raiseExceptionlower=0.0uppers=np.linspace(np.pi,np.pi*2.0,200)
solutions=np.empty(len(uppers))
foriinrange(len(uppers)):
solutions[i], abserr, success=dqags(integrate_ptr, lower, uppers[i], data=fitparam)
ifnotsuccess:
raiseExceptionexcept:
print('doing something else')
fast_function()
iters=1000t_nb=timeit.Timer(fast_function).timeit(number=iters)/itersprint(t_nb)
Thanks.
The text was updated successfully, but these errors were encountered:
Thanks! Unfortunately, I do not think you can’t use numba minpack with cuda. These extensions are compiled for the CPU, so I don’t think there is any way it can run on the GPU. There would need to be a cuda GPU implementation of minpack, which I do not think exists.
Hi @Nicholaswogan.
Thanks for the great tools! I was looking at this stack overflow discussion where you posted an example of using NumbaMinpack for curve fitting.
I was wondering if NumbaMinpack (and this general approach you showed in that thread -- and copied below) can be made to work with Numba's cuda functionality. Do you know if that's possible/straightforward?
Thanks.
The text was updated successfully, but these errors were encountered: