Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv/4.5.3: Add support for DNN on CUDA #8487

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions recipes/opencv/4.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OpenCVConan(ConanFile):
"with_cuda": [True, False],
"with_cublas": [True, False],
"with_cufft": [True, False],
"with_cudnn": [True, False],
"with_v4l": [True, False],
"with_ffmpeg": [True, False],
"with_imgcodec_hdr": [True, False],
Expand All @@ -42,6 +43,7 @@ class OpenCVConan(ConanFile):
"with_imgcodec_sunraster": [True, False],
"neon": [True, False],
"dnn": [True, False],
"dnn_cuda": [True, False],
"detect_cpu_baseline": [True, False],
"nonfree": [True, False],
}
Expand All @@ -65,6 +67,7 @@ class OpenCVConan(ConanFile):
"with_cuda": False,
"with_cublas": False,
"with_cufft": False,
"with_cudnn": False,
"with_v4l": False,
"with_ffmpeg": True,
"with_imgcodec_hdr": False,
Expand All @@ -73,6 +76,7 @@ class OpenCVConan(ConanFile):
"with_imgcodec_sunraster": False,
"neon": True,
"dnn": True,
"dnn_cuda": False,
"detect_cpu_baseline": False,
"nonfree": False,
}
Expand Down Expand Up @@ -139,9 +143,13 @@ def configure(self):
if not self.options.contrib:
del self.options.contrib_freetype
del self.options.contrib_sfm
if not self.options.dnn:
del self.options.dnn_cuda
if not self.options.with_cuda:
del self.options.with_cublas
del self.options.with_cudnn
del self.options.with_cufft
del self.options.dnn_cuda
if bool(self.options.with_jpeg):
if self.options.get_safe("with_jpeg2000") == "jasper":
self.options["jasper"].with_libjpeg = self.options.with_jpeg
Expand Down Expand Up @@ -198,6 +206,9 @@ def validate(self):
raise ConanInvalidConfiguration("Clang 3.x can build OpenCV 4.x due an internal bug.")
if self.options.with_cuda and not self.options.contrib:
raise ConanInvalidConfiguration("contrib must be enabled for cuda")
if self.options.get_safe("dnn_cuda", False) and \
(not self.options.with_cuda or not self.options.contrib or not self.options.with_cublas or not self.options.with_cudnn):
raise ConanInvalidConfiguration("with_cublas, with_cudnn and contrib must be enabled for dnn_cuda")

def build_requirements(self):
if self.options.dnn and hasattr(self, "settings_build"):
Expand Down Expand Up @@ -381,6 +392,7 @@ def _configure_cmake(self):
if self.options.dnn:
self._cmake.definitions["PROTOBUF_UPDATE_FILES"] = True
self._cmake.definitions["BUILD_opencv_dnn"] = True
self._cmake.definitions["OPENCV_DNN_CUDA"] = self.options.get_safe("dnn_cuda", False)

if self.options.contrib:
self._cmake.definitions['OPENCV_EXTRA_MODULES_PATH'] = os.path.join(self.build_folder, self._contrib_folder, 'modules')
Expand All @@ -405,6 +417,7 @@ def _configure_cmake(self):
self._cmake.definitions["CUDA_NVCC_FLAGS"] = "--expt-relaxed-constexpr"
self._cmake.definitions["WITH_CUBLAS"] = self.options.get_safe("with_cublas", False)
self._cmake.definitions["WITH_CUFFT"] = self.options.get_safe("with_cufft", False)
self._cmake.definitions["WITH_CUDNN"] = self.options.get_safe("with_cudnn", False)

self._cmake.definitions["ENABLE_PIC"] = self.options.get_safe("fPIC", True)

Expand Down