gpufit / Gpufit

GPU-accelerated Levenberg-Marquardt curve fitting in CUDA
MIT License
312 stars 92 forks source link

Invalid constraint type #96

Closed henigm closed 3 years ago

henigm commented 3 years ago

I built the package from source on linux and was successful. However when i tried to run the examples i keep getting Invalid constraint type error as shown below. Disabling the type check in gpufit.py doesn't seem to produce good results either. Is there a known solution for this? (using cudatoolkit 10.1)

CUDA available: True
CUDA versions runtime: (10, 1), driver: (10, 2)

RuntimeError                              Traceback (most recent call last)
<ipython-input-1-b56487c73fd3> in <module>
    117                                                                                 initial_parameters,
    118                                                                                 tolerance, max_number_iterations, None,
--> 119                                                                                 estimator_id, None)
    120 
    121     # display results

/opt/venv/lib/python3.6/site-packages/pygpufit/gpufit.py in fit(data, weights, model_id, initial_parameters, tolerance, max_number_iterations, parameters_to_fit, estimator_id, user_info)
    110     return fit_constrained(data, weights, model_id, initial_parameters, tolerance=tolerance,
    111                            max_number_iterations=max_number_iterations, parameters_to_fit=parameters_to_fit,
--> 112                            estimator_id=estimator_id, user_info=user_info)
    113 
    114 

/opt/venv/lib/python3.6/site-packages/pygpufit/gpufit.py in fit_constrained(data, weights, model_id, initial_parameters, constraints, constraint_types, tolerance, max_number_iterations, parameters_to_fit, estimator_id, user_info)
    225         raise RuntimeError('Invalid estimator ID, use an attribute of EstimatorID')
    226     if any(_valid_id(ConstraintType, constraint_type) for constraint_type in constraint_types):
--> 227         raise RuntimeError('Invalid constraint type, use an attribute of ConstraintType')
    228 
    229     # we don't check type of user_info, but we extract the size in bytes of it

RuntimeError: Invalid constraint type, use an attribute of ConstraintType
jkfindeisen commented 3 years ago

You're right. That is a mistake that has been introduced a few commits before. The constraint type check fails when it shouldn't and vice versa. I thought that I'd already fixed it (because I run into the same problem when testing) but apparently not. 44061f05bff3cd0359aa6900176e2d2631de52fa fixes it now. Please try again.

henigm commented 3 years ago

Thank you, that fixed the constraint error. I have tried this fix initially but i was getting results not converging, seems like that is not related to this bug. I will close this and open another one.