opencv versions <3.3.1 do not appears to be compatible with the recently added dev-util/nvidia-cuda-toolkit-9.0.176. Building media-libs/opencv-3.3.0-r4 results in the following error early in the build process: CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CUDA_nppi_LIBRARY (ADVANCED) [list of files using CUDA_nppi_LIBRARY] See also: https://github.com/opencv/opencv/commit/c48807c383094cd240a4a36b53317988f6beabc5 Reproducible: Always
*** Bug 637254 has been marked as a duplicate of this bug. ***
This issue has been further complicated. Anything older than cuda 9 does not support gcc > 5 and fails with the following error: #error -- unsupported GNU version! gcc versions later than 5 are not supported! Now that gcc 6.4.0 is the latest stable, there are no usable versions of opencv if one tries to build with USE=cuda.
Created attachment 512878 [details, diff] Patch for includes in saturate_cast.hpp
Created attachment 512880 [details, diff] Remove reference to compute_20 in CMake file if version >8
Created attachment 512882 [details, diff] Patch for CMake and CUDA > 9
Posted patches that help, cribbed from the git branch. Compilation fails at 31% for reasons I've yet to dig into.
(In reply to Todd Walter from comment #6) > Posted patches that help, cribbed from the git branch. Compilation fails at > 31% for reasons I've yet to dig into. Forget to mention this is against 3.3.0-r4 which is the most recent version in portage.
Error is as follows: [ 33%] Building NVCC (Device) object modules/cudabgsegm/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_mog2.cu.o /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0/modules/core/include/opencv2/core/cuda/vec_math.hpp(203): error: calling a constexpr __host__ function("abs") from a __device__ function("abs") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this. I do not know the consequences of enabling this flag.
(In reply to Todd Walter from comment #6) > Posted patches that help, cribbed from the git branch. Compilation fails at > 31% for reasons I've yet to dig into. I think it makes more sense to create a version 3.3.1 reusing applicable Gentoo patches from 3.3.0 rather than the reverse. That's why I opened this as "<media-libs/opencv-3.3.1" as 3.3.1 specifically support CUDA 9.
Created attachment 513090 [details, diff] Remove reference to compute_20 in CMake file if version >8 Also add required flag to prevent related compile error.
(In reply to Daniel M. Weeks from comment #9) > (In reply to Todd Walter from comment #6) > > Posted patches that help, cribbed from the git branch. Compilation fails at > > 31% for reasons I've yet to dig into. > > I think it makes more sense to create a version 3.3.1 reusing applicable > Gentoo patches from 3.3.0 rather than the reverse. That's why I opened this > as "<media-libs/opencv-3.3.1" as 3.3.1 specifically support CUDA 9. That as a may be, but the patches supplied should fix the problem for what's in tree now. Blender compiles successfully against this, FWIW.
*** Bug 643846 has been marked as a duplicate of this bug. ***
Applying all referenced patches I receive the following error: 2 errors detected in the compilation of "/var/tmp/portage/media-libs/opencv-3.3.0-r4/temp/tmpxft_000043d0_00000000-12_gpu_mat.compute_61.cpp1.ii". -- Removing /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0-abi_x86_64.amd64/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o /usr/bin/cmake -E remove /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0-abi_x86_64.amd64/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:266 (message): Error generating file /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0-abi_x86_64.amd64/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o
(In reply to Samuel Bernardo from comment #13) > Applying all referenced patches I receive the following error: > > 2 errors detected in the compilation of > "/var/tmp/portage/media-libs/opencv-3.3.0-r4/temp/tmpxft_000043d0_00000000- > 12_gpu_mat.compute_61.cpp1.ii". > -- Removing > /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0-abi_x86_64. > amd64/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./ > cuda_compile_generated_gpu_mat.cu.o > /usr/bin/cmake -E remove > /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0-abi_x86_64. > amd64/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./ > cuda_compile_generated_gpu_mat.cu.o > CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:266 (message): > Error generating file > > /var/tmp/portage/media-libs/opencv-3.3.0-r4/work/opencv-3.3.0-abi_x86_64. > amd64/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./ > cuda_compile_generated_gpu_mat.cu.o Forget to mention the errors: /usr/include/bits/floatn.h(61): error: invalid argument to attribute "__mode__" /usr/include/bits/floatn.h(73): error: identifier "__float128" is undefined
Those include files are from the masked glibc 2.26; I think reverting to 2.25 will fix your problem.
(In reply to Todd Walter from comment #15) > Those include files are from the masked glibc 2.26; I think reverting to > 2.25 will fix your problem. Hi Todd, Thanks for your feedback. I'm using profile "default/linux/amd64/17.0 (stable)" with some ebuild keyword unmasked. You're right, I thought that glibc-2.26 was keyword unmasked in profile 17, but actually I'm the responsible to install the new version. I think that I needed to keyword unmasked it in a previous world emerge. When I search for glibc dependencies I can't find now any software depending on it. Since downgrading glibc can turn system unstable, I'll wait for opencv update to glibc-2.26.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b311829f28929c5dd15402b395365ccffb85ecd1 commit b311829f28929c5dd15402b395365ccffb85ecd1 Author: Amy Liffey <amynka@gentoo.org> AuthorDate: 2018-01-21 08:35:52 +0000 Commit: Amy Liffey <amynka@gentoo.org> CommitDate: 2018-01-21 08:36:21 +0000 media-libs/opencv: fix cuda9 and autodownload - Fix cuda 9 compatibility Submitted-by: Todd Walter <twalter@rogers.com> - Remove autodownload tiny_dnn from contrib Submitted-by: Jonathan Scruggs <j.scruggs@gmail.com> - Add PYTHON_COMPAT 3_6 Closes: https://bugs.gentoo.org/637078 Closes: https://bugs.gentoo.org/633844 Closes: https://bugs.gentoo.org/632116 Package-Manager: Portage-2.3.13, Repoman-2.3.3 media-libs/opencv/Manifest | 1 + .../opencv/files/opencv-3.3.0-cuda9-cmake.patch | 87 ++++ .../files/opencv-3.3.0-cuda9-compute20.patch | 21 + .../opencv/files/opencv-3.3.0-cuda9-saturate.patch | 41 ++ media-libs/opencv/metadata.xml | 1 + media-libs/opencv/opencv-3.3.0-r5.ebuild | 466 +++++++++++++++++++++ 6 files changed, 617 insertions(+)