mirror of
https://github.com/zebrajr/opencv.git
synced 2025-12-06 00:19:46 +01:00
Merge pull request #26164 from CSBVision:patch-7
Update haveCUDA() to detect CUDA support at runtime
This commit is contained in:
commit
707ab39454
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user