When installing OpenCV 3.4.1 (I could reproduce the same behavior also with version 3.3.0) with +cuda and +dnn, then the compilation failed, because one of the header files from the OpenCV dnn module has the same name as a cuda header file and the cuda header file is included instead of the OpenCV one.
I think that the error is arising, from a conflict between
/scratch/spackapps/spack-stage/spack-stage-BRyfMH/opencv-3.4.1/modules/dnn/src/ocl4dnn/include/math_functions.hpp
and
/cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/cuda-9.0.176-uqbi62cpkd645vbehqscqy42zhdvfvqq/include/math_functions.hpp
for some reason, the CUDA header file is found first, when actually the header file from the dnn module would need to be included.
The cuda header file then includes another CUDA header file func_macro.h which causes the error message
#error -- incorrect inclusion of a cudart header file
According to
https://devtalk.nvidia.com/default/topic/952579/when-i-compile-cuda-program-always-get-error-incorrect-inclusion-of-a-cudart-header-file/
func_macro.h should never be included.
Expected Result
OpenCV 3.4.1 with CUDA 9.0 should build fine.
Actual Result
[ 36%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/permute_layer.cpp.o
cd /scratch/spackapps/spack-stage/spack-stage-BRyfMH/opencv-3.4.1/spack-build/modules/dnn && /cluster/apps/spack/lib/spack/env/gcc/g++ -DCVAPI_EXPORTS -DHAVE_PROTOBUF=1 -DOPENCV_TRAITS_ENABLE_DEPRECATED -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -isystem /scratch/spackapps/spack-stage/spack-stage-BRyfMH/opencv-3.4.1/spack-build -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/src -I/scratch/spackapps/spack-stage/spack-stage-BRyfMH/opencv-3.4.1/spack-build/modules/dnn -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/cudev/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/core/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/imgproc/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/src/ocl4dnn/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/ts/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/imgcodecs/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/videoio/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/highgui/include -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/test -I/cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/perf -isystem /cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/protobuf-3.1.0-l4okq4ruz7pclkxnr7kcsoghssoprscg/include -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Winit-self -Wpointer-arith -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -Wno-shadow -Wno-parentheses -Wno-maybe-uninitialized -Wno-sign-promo -Wno-missing-declarations -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-unused-local-typedefs -Wno-sign-compare -Wno-sign-promo -Wno-undef -Wno-ignored-qualifiers -Wno-extra -Wno-unused-function -Wno-deprecated-declarations -Wno-error=non-virtual-dtor -Wno-unused-parameter -Wno-undef -Wno-ignored-qualifiers -Wno-enum-compare -Wno-deprecated-declarations -Wno-invalid-offsetof -O2 -g -DNDEBUG -fPIC -o CMakeFiles/opencv_dnn.dir/src/layers/permute_layer.cpp.o -c /cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/src/layers/permute_layer.cpp
In file included from /cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/cuda-8.0.61-mxdqob5lveng3f2utljrysrx4vjp7g3m/include/math_functions.hpp:1674:0,
from /cluster/apps/spack/var/spack/stage/opencv-3.4.1-zxmgmfmwzkooupmg24dzntqp2h2dqy3k/opencv-3.4.1/modules/dnn/src/layers/mvn_layer.cpp:46:
/cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/cuda-8.0.61-mxdqob5lveng3f2utljrysrx4vjp7g3m/include/crt/func_macro.h:50:2: error: #error -- incorrect inclusion of a cudart header file
#error -- incorrect inclusion of a cudart header file
^
Steps to reproduce the issue
spack install --no-checksum opencv@3.4.1+core+cuda+dnn+gtk+png+highgui+imgproc+shared+tiff+zlib~python~eigen ^cmake@3.8.0+ncurses+openssl ^protobuf@3.1.0+shared ^cuda@8.0.61 ^gtkplus@2.24.31+X ^libtiff@4.0.6 ^libpng@1.6.27 ^python@2.7.13+tk ^libpthread-stubs@0.3 ^glib@2.49.7+libmount ^xproto@7.0.29 ^libx11@1.6.3 ^zlib@1.2.11 ^flex@2.6.1 ^gettext@0.19.8.1+bzip2+curses+git+libunistring+libxml2+tar+xz ^util-linux@2.29.1 ^freetype@2.7 ^fontconfig@2.11.1 %gcc@4.8.5 arch=linux-centos7-x86-64
Information on your system
Plattform: CentOS Linux release 7.4.1708 (Core)
Kernel: 3.10.0-693.11.6.el7.x86_64
When installing OpenCV 3.4.1 (I could reproduce the same behavior also with version 3.3.0) with +cuda and +dnn, then the compilation failed, because one of the header files from the OpenCV dnn module has the same name as a cuda header file and the cuda header file is included instead of the OpenCV one.
I think that the error is arising, from a conflict between
/scratch/spackapps/spack-stage/spack-stage-BRyfMH/opencv-3.4.1/modules/dnn/src/ocl4dnn/include/math_functions.hppand
/cluster/spack/apps/linux-centos7-x86_64/gcc-4.8.5/cuda-9.0.176-uqbi62cpkd645vbehqscqy42zhdvfvqq/include/math_functions.hppfor some reason, the CUDA header file is found first, when actually the header file from the dnn module would need to be included.
The cuda header file then includes another CUDA header file func_macro.h which causes the error message
#error -- incorrect inclusion of a cudart header fileAccording to
https://devtalk.nvidia.com/default/topic/952579/when-i-compile-cuda-program-always-get-error-incorrect-inclusion-of-a-cudart-header-file/
func_macro.h should never be included.
Expected Result
OpenCV 3.4.1 with CUDA 9.0 should build fine.
Actual Result
Steps to reproduce the issue
spack install --no-checksum opencv@3.4.1+core+cuda+dnn+gtk+png+highgui+imgproc+shared+tiff+zlib~python~eigen ^cmake@3.8.0+ncurses+openssl ^protobuf@3.1.0+shared ^cuda@8.0.61 ^gtkplus@2.24.31+X ^libtiff@4.0.6 ^libpng@1.6.27 ^python@2.7.13+tk ^libpthread-stubs@0.3 ^glib@2.49.7+libmount ^xproto@7.0.29 ^libx11@1.6.3 ^zlib@1.2.11 ^flex@2.6.1 ^gettext@0.19.8.1+bzip2+curses+git+libunistring+libxml2+tar+xz ^util-linux@2.29.1 ^freetype@2.7 ^fontconfig@2.11.1 %gcc@4.8.5 arch=linux-centos7-x86-64Information on your system
Plattform: CentOS Linux release 7.4.1708 (Core)
Kernel: 3.10.0-693.11.6.el7.x86_64