1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #26164 from CSBVision:patch-7

Update haveCUDA() to detect CUDA support at runtime
This commit is contained in:
Alexander Smorkalov
2024-12-26 15:56:03 +03:00
committed by GitHub
2 changed files with 16 additions and 7 deletions
+15
View File
@@ -107,3 +107,18 @@ void Net::Impl::initCUDABackend(const std::vector<LayerPin>& blobsToKeep_)
CV__DNN_INLINE_NS_END
}} // namespace cv::dnn
#endif // HAVE_CUDA
namespace cv { namespace dnn {
bool haveCUDA()
{
#ifdef HAVE_CUDA
int dev = 0;
static bool ret = (cudaGetDevice(&dev) == cudaSuccess);
return ret;
#else
return false;
#endif
}
}} // namespace cv::dnn
+1 -7
View File
@@ -29,13 +29,7 @@ namespace cv { namespace dnn {
return id == DNN_TARGET_CUDA_FP16 || id == DNN_TARGET_CUDA;
}
constexpr bool haveCUDA() {
#ifdef HAVE_CUDA
return true;
#else
return false;
#endif
}
bool haveCUDA();
#ifdef HAVE_CUDA
namespace cuda4dnn { namespace csl {