Ask Your Question
0

How to reproduce OpenCV official build locally

asked 2018-01-13 03:46:11 -0600

Pzixel gravatar image

updated 2018-01-15 06:48:43 -0600

I used to use OpenCV build vc14_vc15from the official github page: https://github.com/opencv/opencv/rele... . But I have realised that it is compiled without CUDA support which I need, e.g. see build/include/opencv2 screenshot

enter image description here

When I build it myself (e.g. using this instruction) I don't have any include folder at all. But I need it because I need cudaobjdetect.hpp and several other guys (such as features2d.hpp) being located here.

Why my local build doesn't look like those in opencv-3.4.0-vc14_vc15.7z and how can I achieve same result, but with several extra CMake switches (like CUDA in this example)? I mean I want OpenCV to be built with CUDA support and cudaobject.hpp located in build/include/opencv2 folder.


Ok, I configured CMake with following options:

CMAKE_OPTIONS='-DWITH_CUDA:BOOL=ON -DCUDA_ARCH_BIN="5.2" -DCUDA_ARCH_PTX="" -DBUILD_opencv_java:BOOL=OFF -DBUILD_opencv_python:BOOL=OFF -DBUILD_opencv_python2:BOOL=OFF -DBUILD_opencv_python3:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DINSTALL_CREATE_DISTRIB:BOOL=ON'

But in this case OpenCV just doesn't get built, see log part with error: https://gist.github.com/Pzixel/496994...

For more context: here is full log

CUDA is installed with following flags:

Start-Process -FilePath "cuda_9.1.exe" -ArgumentList "-s nvcc_9.1 cublas_9.1 cublas_dev_9.1 cufft_9.1 cufft_dev_9.1 npp_9.1 npp_dev_9.1" -Wait
edit retag flag offensive close merge delete

Comments

see this post https://devtalk.nvidia.com/default/to... I have got same error... CUDA 9.1 and msvc 2017 is it compatibel?

LBerger gravatar imageLBerger ( 2018-01-15 06:08:39 -0600 )edit

Ye, just change the header value. Here is my script for it: https://github.com/Pzixel/cv-rs/blob/... . It's ok to change it because it how NVidia itself is doing it: https://devtalk.nvidia.com/default/to...

Pzixel gravatar imagePzixel ( 2018-01-15 06:23:52 -0600 )edit

Hmm, it seems to be a known incompatibility, see post at `12/29/2017 08:38 PM on last url. Beign said, that's funny enough that they have broken compatibility with minor update (15.3 -> 15.4). Going to search some workarounds...

Pzixel gravatar imagePzixel ( 2018-01-15 06:59:44 -0600 )edit

Ok, I managed to configure AppVeyor to use MSVC 1911 which is working fine with CUDA 9.1. HOwever, build is failing because of timeout. Is there any way to speed it up? Build log: https://ci.appveyor.com/project/nebgn...

Pzixel gravatar imagePzixel ( 2018-01-15 09:37:46 -0600 )edit

Just for info, in windows "to reproduce OpenCV official build locally" and get the same directory structure you need to build the INSTALL project in Visual Studio and look inside the install directory.

cudawarped gravatar imagecudawarped ( 2018-02-14 02:11:48 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-01-13 07:14:08 -0600

LBerger gravatar image

updated 2018-01-13 07:16:22 -0600

you will need git and cmake. you can follow this tutorial

You have to set -DWITH_CUDA:BOOL=ON instead of OFF

If you don't want tou use this scriptyou can use cmake-gui

edit flag offensive delete link more

Comments

@LBerger ty, i'l try it asap

Pzixel gravatar imagePzixel ( 2018-01-13 08:13:24 -0600 )edit
1

I have tried it. It reproduces an official build, horray! :) Now I'm trying to use CUDA switch to generate it... Don't know how much time it takes.. The last time I tried it took 6 hours or something. I heard that you can specify architecture for CUDA to make reduce this time, but i didn't find any good documentation which switshes what values must have to make it happen.

Pzixel gravatar imagePzixel ( 2018-01-13 09:19:05 -0600 )edit

Yes you should use only one architecture to reduce compilation time (may be one hour with one architecture) May be this blog can help you

LBerger gravatar imageLBerger ( 2018-01-13 09:34:55 -0600 )edit

For CUDA build time, see also.

Eduardo gravatar imageEduardo ( 2018-01-13 14:04:46 -0600 )edit

@LBerger I updated my question, see it, please. I followed this tutorial, however, I can't build the project.

Pzixel gravatar imagePzixel ( 2018-01-15 04:48:26 -0600 )edit

I think I have to write a separate question, because in theory this one is working. However, on practice build never finishes.

Pzixel gravatar imagePzixel ( 2018-01-15 12:06:39 -0600 )edit

At line 1814 i have got exactly same error with :

1>--     CMake generator:             Visual Studio 15 2017 Win64
1>--     CMake build tool:            C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe
1>--     MSVC:                        1912

and error is

32>gpu_mat.cu
32>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\type_traits(504): error : expression must have a constant value
32>
32>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\type_traits(505): error : expression must have a constant value
32>
LBerger gravatar imageLBerger ( 2018-01-15 13:14:48 -0600 )edit

@LBerger it's because you are using latest VS. If you use VS2017Update1 then it works as expected. MS has broken something with latest update.

Pzixel gravatar imagePzixel ( 2018-01-15 13:21:19 -0600 )edit

Using

94> --     CMake generator:             Visual Studio 14 2015 Win64
94>  --     CMake build tool:            C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
94>  --     MSVC:                        1900
94>  --       AVX2 (9 files):

and

94>  --   NVIDIA CUDA:                   YES (ver 9.1, CUFFT CUBLAS NVCUVID)
94>  --     NVIDIA GPU arch:             50
94>  --     NVIDIA PTX archs:

It's OK after 34 minutes i7-5820 ssd disk only opencv and no opencv_contrib

LBerger gravatar imageLBerger ( 2018-01-15 14:20:24 -0600 )edit

@LBerger this is why I marked is as an answer. However, one hour is too much for CI which cancels the build if it takes so much time, so I'm searching for some way to actually build in less than hour. I think I may actually exclude opencv_contrib. I'l try it tomorrow, thank you.

Pzixel gravatar imagePzixel ( 2018-01-15 14:24:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-01-13 03:46:11 -0600

Seen: 796 times

Last updated: Jan 15 '18