OpenCV installation problem : nppiGraphcutInitAlloc not declared

Hello!

I’m trying to install OpenCV 3.1.0 on my TX1, with JetPack 2.3.1, following this guide:
https://devtalk.nvidia.com/default/topic/917386/jetson-tx1/usb-3-0-port-unstable-on-jetson-tx1-/post/4835793/#4835793

However when I reach 95% I get a bunch of build errors like:

/home/ubuntu/Downloads/opencv/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
     typedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);

I have downloaded the OpenCV source code from http://opencv.org/downloads.html and built it as described in the link above.

As far as I can work out this is due to OpenCV 3.1.0 being released before Cuda V8.0.33 but then it somehow seems to have been fixed, although I’m not sure how to apply this fix… (got this info from here: https://github.com/opencv/opencv/issues/6677).

Any ideas on how to fix this?

So I’ve done some more research, and it seems that opencv3.1.0 downloaded from the opencv.org website is not compatible with Cuda 8, and that I need to download the latest version from github instead according to http://dev.t7.ai/jetson/opencv/.

With that said, I’m now stuck with a half-compiled/installed version of OpenCV, could I simply “make clean” or

sudo find / -name "*opencv*" -exec rm -i {} \;

Or is there something else to do? maybe try the sudo make uninstall to make the uninstall manifest and then try that?
I don’t have opencv4tegra installed so removing all the files related to opencv should be ok?

Do you have cuda-npp-8.0 installed ?
What is the output of :

sudo apt search npp |grep installed

?

If is it not installed, you may try to install with:

sudo apt-get install cuda-npp-dev-8-0

Not sure the dev package is required, but this may solve more issues.

This issue could be resolved by following instructions described on this web page (sorry it’s in Chinese).

http://www.itdadao.com/articles/c15a584954p0.html

More precisely, modify this file “opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp” by replacing

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)

with

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)  || (CUDART_VERSION >= 8000)

Hi again,
yes it seems that jkjung13’s answer would work, however now I’m stuck with OpenGL support instead…

The output of

sudo apt search npp |grep installed

is

cuda-npp-8-0/unknown,now 8.0.34-1 arm64 [installed,automatic]
cuda-npp-dev-8-0/unknown,now 8.0.34-1 arm64 [installed,automatic]

However, I’ve tried to compile it and install it a couple of times now, and I can never seem to get it to work, my error on the compilation is :

[ 14%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o
In file included from /home/ubuntu/Downloads/opencv/opencv-3.1.0/modules/core/src/opengl.cpp:48:0:
/usr/local/cuda-8.0/include/cuda_gl_interop.h:64:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
 #error Please include the appropriate gl headers before including cuda_gl_interop.h

So now i seem to have opengl problems…

My CMake command is:

cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D WITH_LIBV4L=ON -D CMAKE_BUILD_TYPE=RELEASE -D CUDA_FAST_MATH=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..

I’ll try to work it out, but if you have any ideas I would be grateful!

I would suggest to look for any configuration error with cmake-gui.
You may look at :https://devtalk.nvidia.com/default/topic/986754/-quot-cannot-find-lopencv_nonfree-quot-/?offset=4#5052065 if you don’t have it yet. (Don’t take care of the non-free part if you don’t need it).

I took a look at CMake GUI, there is no configuration errors…
I have also had a look at http://dev.t7.ai/jetson/opencv/, and tried to install the github version non-succesfully…

Looking at line 64 of file /usr/local/cuda-8.0/include/cuda_gl_interop.h, it complains because GL_VERSION is not set.
This should be set by GL header (such as GL/gl.h) that should be included before including this file.

Yes, well in /usr/local/cuda-8.0/include/cuda_gl_interop.h, the error is due to this snippet of code:

#if defined(__arm__) || defined(__aarch64__)
#ifndef GL_VERSION
#error Please include the appropriate gl headers before including cuda_gl_interop.h
#endif
#else
#include <GL/gl.h>
#endif

In the case of the TX1, aarch64 would be defined, and <GL/gl.h> wouldn’t be included, therefore I would suspect that GL_VERSION would be defined elsewhere, either in the included files “builtin_types.h”, “host_defines.h” or possibly in the project(?).

As far as I can find, no GL_VERSION is defined in any of the header files or their includes…

My CMake output regarding OpenGL is:

--   GUI: 
--     QT:                          NO
--     GTK+ 2.x:                    YES (ver 2.24.30)
--     GThread :                    YES (ver 2.48.1)
--     GtkGlExt:                    YES (ver 1.2.0)
--     OpenGL support:              YES (/usr/lib/aarch64-linux-gnu/libGLU.so /usr/lib/aarch64-linux-gnu/libGL.so)
--     VTK support:                 NO

Which seems to be correct when comparing to others successful builds. When I check the advanced setting in CMake GUI, no GL_VERSION entry is found, and the OpenGL related info is (except what is seen above):

OPENGL_INCLUDE_DIR : /usr/include
OPENGL_xmesa_INCLUDE_DIR : OPENGL_xmesa_INCLUDE_DIR-NOTFOUND

It seems that the xmesa is not needed to build OpenCV according to a quick google search.
The only definition of GL_VERSION I can find is in gl.h.

At this point, I’m starting to have doubts about compiling OpenCV with OpenGL, so I might just skip OpenGL support (see http://dev.t7.ai/jetson/opencv/ regarding the WITH_OPENGL=ON flag)…

Ok, so I have now compiled and installed OpenCV successfully without OpenGL!

Here is what I did:
Used these two guides - https://devtalk.nvidia.com/default/topic/917386/jetson-tx1/usb-3-0-port-unstable-on-jetson-tx1-/post/4835793/#4835793 & http://dev.t7.ai/jetson/opencv/.

Modified “opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp” by replacing

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)

with

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)  || (CUDART_VERSION >= 8000)

used this CMake command:

cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D WITH_LIBV4L=ON -D CMAKE_BUILD_TYPE=RELEASE -D CUDA_FAST_MATH=ON -D BUILD_EXAMPLES=OFF -D ENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..

Compiled and installed!

Thanks for all the help guys, maybe I’ll return to try to get OpenGL to work some time later.