TX1 OpenCV Build [Solved]

Hi,

I attempted to build opencv-2.4.11 for Jetson TX1 with cuda7.0-71 and managed to build successfully.

However my application failed to execute when it try using the gpu functions such as gpu::matchTemplate.

The following error are observed.
[i]NCV Assertion Failed: cudaError_t=18, file=opencv-2.4.11/modules/gpu/src/NVidia/NPP_staging/NPP_staging.cu, line=336
NCV Assertion Failed: NcvStat=4, file=opencv-2.4.11/modules/gpu/src/NVidia/NPP_staging/NPP_staging.cu, line=464
NCV Assertion Failed: NcvStat=4, file=opencv-2.4.11/modules/gpu/src/NVidia/NPP_staging/NPP_staging.cu, line=578
OpenCV Error: Gpu API call (NCV_FILE_ERROR [Code = 4]) in sqrIntegral, file opencv-2.4.11/modules/gpu/src/imgproc.cpp, line 636
terminate called after throwing an instance of ‘cv::Exception’
what(): opencv-2.4.11/modules/gpu/src/imgproc.cpp:636: error: (-217) NCV_FILE_ERROR [Code = 4] in function sqrIntegral

Aborted
[/i]

OpenCV Build command used:
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_BIN=“3.2” -DCUDA_ARCH_PTX=“” -DCMAKE_TOOLCHAIN_FILE=…/platforms/Linux/arm=-gnueabi.toolchain.cmake …

During my opencv build, I saw some warning about target-cpu-architecture being deprecated.

I suspect my openCV build might not been configured correctly, however I managed to get it to work in Jetson TK1, so I’m not too sure what went wrong.

Hi There. A few things. You’re probably aware of this, but you can actually download a special version of OpenCV optimized for Tegra devices (2.4.12, I believe.) That should work out of the box

As for your error, I’m not sure about OCV2, but I’ve been building OpenCV3 over and over on my Tx1 (for various reasons…), and the commands I run are

for an out of source build

cd opencv-master;
mkdir build;
cd build;
cmake -DCMAKE_BUILD_TYPE=RELEASE …;

At which point CUDA gets picked up with the correct architecture. In the past this has just worked for me, and I haven’t had to specify a specific cmake toolcahin file or anything like that. However if there was a reason for you to format your cmake command like that, then you may have more knowledge than me and are ignore my advice.

Hi, I am aware there is prebuilt binary for TX1 but not so much about a special version of OpenCV source, so if you don’t mind, can you point me to the link?

As for the reason to my cmake command, I tried follow example provided to cross compile TK1 OpenCV (Jetson/Installing OpenCV - eLinux.org), which I realize may not be compatible as GPU used are different.

I am unsure what should I set for my CUDA_ARCH_BIN and CUDA_ARCH_PTX in order to cross compile TX1 OpenCV.

Thanks

I managed to cross compile OpenCV on TX1 by changing the CUDA_ARCH_BIN and CUDA_ARCH_PTX to ‘5.2’

swl, thanks for the update re: CUDA_ARCH_BIN / PTX settings.

I just spent the a day trying to figure this out. With your solution, OpenCV cuda is working here as well.