How to ues gpu to accelerate test image with classification.cpp

77 views
Skip to first unread message

任佑顏

unread,
Jun 4, 2016, 12:49:51 AM6/4/16
to Caffe Users
Hello everyone.
I have some question!
May I have anyone to solution my question.

I complier classification.cpp.
I put the clock_t on the input image

Like this:
  clock_t clockbegin,clockend;
  clockbegin = clock();
  cv::Mat img = cv::imread(file, -1);
  //CHECK(!img.empty()) << "Unable to decode image " << file;
  std::vector<Prediction> predictions = classifier.Classify(img);
  clockend = clock();
  printf("%Lf\n", (long double)(clockend - clockbegin));

And the time is about 0.3s.
But it's maybe not use gpu.
How to ues gpu to accelerate this program classification.cpp.
And the time will less than 0.05s.

Thank everyone for help.
Have a nice day.

Hossein Hasanpour

unread,
Jun 5, 2016, 3:22:55 PM6/5/16
to Caffe Users
Simply write :
 Caffe::set_mode(Caffe::GPU);
inside Classifier's constructor and you are good to go. 

任佑顏

unread,
Jun 6, 2016, 11:15:15 PM6/6/16
to Caffe Users
To Hossein Hasanpour:
Thank you very much!!
I think it's too late to classify a image.
First time to classify a image,I think it almost 0.01s.
But it cost about 0.4s.
So I think it isn't a "GPU MODE"
But it looks already a GPU MODE.
Thank you so much 
Have a nice day
Reply all
Reply to author
Forward
0 new messages