Skip to content

Commit

Permalink
Merge pull request #1171 from tinohager/master
Browse files Browse the repository at this point in the history
Get gpu count and name
  • Loading branch information
AlexeyAB authored Jul 10, 2018
2 parents cfc5fed + c021841 commit b956a66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/yolo_v2_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ int dispose() {
return 1;
}

int get_device_count() {
#ifdef GPU
int count = 0;
cudaGetDeviceCount(&count);
return count;
#else
return -1;
#endif // GPU
}

int get_device_name(int gpu, char* deviceName) {
#ifdef GPU
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, gpu);
std::string result = prop.name;
std::copy(result.begin(), result.end(), deviceName);
return 1;
#else
return -1;
#endif // GPU
}

#ifdef GPU
void check_cuda(cudaError_t status) {
if (status != cudaSuccess) {
Expand Down
2 changes: 2 additions & 0 deletions src/yolo_v2_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ extern "C" YOLODLL_API int init(const char *configurationFilename, const char *w
extern "C" YOLODLL_API int detect_image(const char *filename, bbox_t_container &container);
extern "C" YOLODLL_API int detect_mat(const uint8_t* data, const size_t data_length, bbox_t_container &container);
extern "C" YOLODLL_API int dispose();
extern "C" YOLODLL_API int get_device_count();
extern "C" YOLODLL_API int get_device_name(int gpu, char* deviceName);

class Detector {
std::shared_ptr<void> detector_gpu_ptr;
Expand Down

0 comments on commit b956a66

Please sign in to comment.