mirror of
https://github.com/opencv/opencv.git
synced 2025-07-20 19:17:36 +08: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
|
CV__DNN_INLINE_NS_END
|
||||||
}} // namespace cv::dnn
|
}} // namespace cv::dnn
|
||||||
#endif // HAVE_CUDA
|
#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;
|
return id == DNN_TARGET_CUDA_FP16 || id == DNN_TARGET_CUDA;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool haveCUDA() {
|
bool haveCUDA();
|
||||||
#ifdef HAVE_CUDA
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_CUDA
|
#ifdef HAVE_CUDA
|
||||||
namespace cuda4dnn { namespace csl {
|
namespace cuda4dnn { namespace csl {
|
||||||
|
Loading…
Reference in New Issue
Block a user