Update op_cuda.hpp

This commit is contained in:
CSBVision 2024-09-20 10:44:21 +02:00 committed by Björn Böken
parent f503890c2b
commit fab419a484
2 changed files with 16 additions and 7 deletions

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

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 {