diff --git a/dlib/dnn/cuda_dlib.cu b/dlib/dnn/cuda_dlib.cu index 8b4824b11..fb4fa4d13 100644 --- a/dlib/dnn/cuda_dlib.cu +++ b/dlib/dnn/cuda_dlib.cu @@ -27,6 +27,14 @@ namespace dlib return dev; } + int get_num_devices ( + ) + { + int num_devices; + CHECK_CUDA(cudaGetDeviceCount(&num_devices)); + return num_devices; + } + // ----------------------------------------------------------------------------------- __global__ void _cuda_multiply1(float* d, const float* s1, const float* s2, size_t n) diff --git a/dlib/dnn/cuda_dlib.h b/dlib/dnn/cuda_dlib.h index 1a8bfdc28..ab81d44e1 100644 --- a/dlib/dnn/cuda_dlib.h +++ b/dlib/dnn/cuda_dlib.h @@ -22,6 +22,9 @@ namespace dlib int get_device ( ); + int get_num_devices ( + ); + // ----------------------------------------------------------------------------------- void multiply ( @@ -165,6 +168,9 @@ namespace dlib inline int get_device ( ){ return 0; } + int get_num_devices ( + ) { return 1; } + #endif // DLIB_USE_CUDA }