Xtra-Computing / thundersvm

ThunderSVM: A Fast SVM Library on GPUs and CPUs
Apache License 2.0
1.55k stars 215 forks source link

thundersvm.dense_model_scikit not parsing parameter? #210

Open civilinformer opened 4 years ago

civilinformer commented 4 years ago

I am able to run thundersvm but under certain multithreaded environments I get this error:

lib/python3.6/site-packages/thundersvm-0.3.4-py3.6.egg/thundersvm/thundersvm.py", line 237, in _dense_fit n_classes, self._train_succeed, c_void_p(self.model)) ctypes.ArgumentError: argument 19: <class 'TypeError'>: Don't know how to convert parameter 19

I tried printing out parameter 19, which I believe is either just max_iter or n_jobs (depending on whether the count is from 1 or zero) and they are normal: self.max_iter, # 18 self.n_jobs, # 19

max_iter 3126 n_jobs 8

Any idea to why this might be failing?

civilinformer commented 4 years ago

This fix worked:

       `c_int(self.max_iter), # 18
        c_int(self.n_jobs), # 19`
zeyiwen commented 4 years ago

Thanks for the feedback. It doesn't look like a common issue. Most of the users of ThunderSVM don't have this problem.

Would you explain the reason for the ctypes.ArgumentError? Usually, float type needs to be explicitly converted to c_float.

civilinformer commented 4 years ago

I agree that it is a very rare enviroment where this occurs. Hopefully I have built something special then. In any case the fix occurred to me because I saw that there are other integer arguments to thundersvm.dense_model_scikit, including: weight_label = (c_int * weight_size)() n_features = (c_int * 1)() n_classes = (c_int * 1)() self._train_succeed = (c_int * 1)(). max_iter and n_jobs are integers, also, so it seems that they need to be converted to ctype integers to work properly. Maybe this is broken but you did not notice because the conversion is normally equivalent or ignored. Not sure what the default is here or how the library works. Just guessing.