Building OpenCV with CUDA support Error

asked 2015-02-12 02:29:30 -0600

updated 2015-02-12 03:01:52 -0600

Recently I am trying to build OpenCV with CUDA support, and I met problem while building the module cudaarithm.

OpenCV source:git cloned from : http://github.com/Itseez/opencv.git

OpenCV branch: master branch

OpenCV commit:

`commit 5466e321b8c8f97536002a357e5b7ff49a5d2bf9, on Tue Feb 10 12:17:11 2015 +0000`

CUDA version: CUDA 6.5

Hardware: MacBook Pro (13-inch, Mid 2010)

GPU: NVIDIA GeForce 320M 256 MB

OS Version: OS X Yosemite

Steps I used:

1. cd in OpenCVSource, then mkdir myrelease, and cd myrelease

2. cmake -DPLANTUML_JAR=/usr/local/Cellar/plantuml/8002  -D BUILD_DOCS=1 -DPYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib -DPYTHON2_INCLUDE_DIR=/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DPYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib -DPYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/include/python3.4m -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -Wno-dev -DNVCC_FLAGS_EXTRA="-Xcompiler -stdlib=libstdc++; -Xlinker -stdlib=libstdc++" -DOPENCV_EXTRA_CXX_FLAGS=" -stdlib=libstdc++" -DOPENCV_EXTRA_EXE_LINKER_FLAGS="-stdlib=libstdc++" ..

3. make  VERBOSE=1

Expect Result: Building success without error

Actual Result: when building OpenCVSource/modules/cudaarithm/src/cuda/transpose.cu, error happend like below:

/Users/Hawk/Documents/study/DIP/OpenCV/OpenCVSource/modules/cudaarithm/src/cuda/transpose.cu(61): *error: identifier "getInputMat" is undefined*

/Users/Hawk/Documents/study/DIP/OpenCV/OpenCVSource/modules/cudaarithm/src/cuda/transpose.cu(67): *error: identifier "getOutputMat" is undefined*

/Users/Hawk/Documents/study/DIP/OpenCV/OpenCVSource/modules/cudaarithm/src/cuda/transpose.cu(92): *error: identifier "syncOutput" is undefined*

Then what action I take:

  1. check the code and I found these undefined symboles are defined in OpenCVSource/modules/core/include/opencv2/core/private.cuda.hpp

  2. check the code and I confrim that the "transpose.cu" file include "opencv2/core/private.cuda.hpp"

  3. check the building log, and I the confirm the private.cuda.hpp is in the search path of header file

  4. cp "opencv2/core/private.cuda.hpp" as another file "opencv2/core/hawk.hpp", and then edit "transpose.cu" to include this new file, and I found the "undifined symbole error" disapeared.

Although this is a workable workaround, I would like know whether the original OpenCV source cannot be compiled.

edit retag flag offensive close merge delete

Comments

1

Try to keep your title clean and focussed on the topic itself. As to the error, people will look into it and report back :)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-12 03:03:27 -0600 )edit

thank you for the suggestion

yourwanghao gravatar imageyourwanghao ( 2015-02-12 03:40:18 -0600 )edit
1

All, I think I found the problem cause.

Before I met such problem, I've already build and install OpenCV using older code from the git repo. So that there already have header files in my /usr/local/include/opencv2, especially there is /usr/local/include/opencv2/core/private.cuda.hpp.

However, it is an older one that doesn't define the symbols reporting undefined in above question. At the same time I found during the building nvcc have -I/usr/local/include in the command line, so that it use wrong private.cuda.hpp. As you know it should use the one in OpenCVSource, not the older installed one.

I think the solution is to gracefully remove the original installed OpenCV from my computer, then build again. I am trying and I will report later.

yourwanghao gravatar imageyourwanghao ( 2015-02-12 04:39:54 -0600 )edit