Ask Your Question
0

SVM on CUDA

asked 2019-01-18 08:27:48 -0600

vps gravatar image

updated 2019-01-18 08:39:16 -0600

Hi, I am using SVM. I have trained SVM and stored matrix in .xml file. I want to predict the label for each row. So, I am using below snippet in cuda Kernel function.

Ptr<svm> svm = SVM::load("trainedSVM10.xml"); classId = svm->predict(row);

but I am getting the error message is

" __host__ function("predict") from a __global__ function("kernelSVM")"

Is it possible to use OpenCV SVM on CUDA? Let me know, in case more information required. NOTE: It is working on CPU. Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2019-01-18 08:42:05 -0600

berak gravatar image

updated 2019-01-18 08:43:34 -0600

no, it is not possible to run an SVM on the GPU (at all ! not even with opencl.)

(it does not accept GpuMat's as input, and simply putting the svm code into a cuda kernel is "not enough")

edit flag offensive delete link more

Comments

Hi @berak, I have a few questions.

1) SVM is used in GPU version of HOG. Can we use of same detection method here? Linear SVM is used for the HOG. I am using nonlinear multiclass SVM. 2) Is there any alternate for this problem? (library or ..)

Thanks.

vps gravatar imagevps ( 2019-01-18 09:06:51 -0600 )edit
2

1) indeed the HOGDescriptor is using it's own binary LINEAR SVM implementation. and all required there is a simple dot product between the (pretrained) support vector and the current feature, so that's easy to do ! ;)

2) idk. but personally, i've been quite successfully using custom SVM kernels with opencv's SVM (like SSE optimized stuff, 2 or 3 times speedup)

berak gravatar imageberak ( 2019-01-18 09:40:51 -0600 )edit

@berak..Thanks for the reply. You are correct :) Actually, I want to use the support vector file which I have trained by using OpenCV on CPU. I just wanted to apply that support vectors on new data by using Cuda. but I think, it is very complicated as I am using multiclass SVM.

let me correct, If I am wrong. To create SVM in order to work with Cuda. First, I have to train the customize kernel which can work with cuda. Then, use the support vectors with the same kernel. But can you refer good material about this?

vps gravatar imagevps ( 2019-01-18 09:59:37 -0600 )edit
1

the HOG cpu code is here , then it gets thresholded against rho, and that's all ;)

and opencv's svm kernels are here

apart from that, no, i've no resources about this in general, and no 1st hand exp. with cuda specifically ;(

berak gravatar imageberak ( 2019-01-18 10:03:09 -0600 )edit

@berak..Thnak you for the links. But maybe the Cuda SVM version will be updated in the next OpenCV version release. :)

vps gravatar imagevps ( 2019-01-18 10:07:24 -0600 )edit

But maybe the Cuda SVM version will be updated

i do not think, that's likely to happen, given how small the core dev team is, after the intel takeover, and also the current "let's move all things cuda out !" and "deep learning über alles" spirit there ;(

again, if you can achieve something, they'll happily accept your contribution, but nothing will happen "on it's own" there, i'm afraid.

berak gravatar imageberak ( 2019-01-18 10:12:06 -0600 )edit
2

@berak..Nowadays, CUDA is very important to speed the process. Sure, if I achieve something important, I will happy to contribute.

vps gravatar imagevps ( 2019-01-18 10:22:01 -0600 )edit
1

i'll be happy to see this ;)

berak gravatar imageberak ( 2019-01-18 10:25:33 -0600 )edit

Berak kommst du aus Deutschland?

holger gravatar imageholger ( 2019-01-18 10:58:40 -0600 )edit
1

@holger, -- ein westphale in berlin ...

berak gravatar imageberak ( 2019-01-18 11:00:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-18 08:27:48 -0600

Seen: 982 times

Last updated: Jan 18 '19