Ask Your Question
0

Building OpenCV with CUDA support

asked 2019-04-14 17:14:46 -0500

zbadioh gravatar image

I tried compiling OpenCV from source with added CUDA support with CMake, and while I'm building it, it says "CUDA: YES" but after it's done if I test it, it doesn't have CUDA support. Also it doesn't build python cv2.pyd file even if I set python paths and enabled python build.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-15 08:53:39 -0500

Hi, are you building with windows or linux, OpenCV version 3.4 or 4? If 4 have you included the contrib repo? If windows are you following steps similar to this guide, which uses Visual Studio 2017, CUDA 10.1, and Anaconda?

Does the CMake output of modules to be built (shown below) include python2

--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto

and similar output for the following?

--   Python 2:
--     Interpreter:                 C:/Users/xx/Anaconda2/python.exe (ver 2.7.14)
--     Libraries:                   C:/Users/xx/Anaconda2/libs/python27.lib (ver 2.7.14)
--     numpy:                       C:/Users/xx/Anaconda2/lib/site-packages/numpy/core/include (ver 1.13.3)
--     install path:                C:/Users/xx/Anaconda2/Lib/site-packages/cv2/python-2.7

If you are building INSTALL in version 4.1.0 then the cv2.pyd file no longer gets copied to the install\python\cv2\python-2.x\ directory and can instead be found in the lib directory, have you checked there?

edit flag offensive delete link more

Comments

Thanks for your reply, I followed one of his older guides without Anaconda. I am using windows 10 and building OpenCV 4.1 with CUDA 10.0 (Do I need 10.1?). I want python3 support but his site seems to be down so I can't check out that link currently..

zbadioh gravatar imagezbadioh ( 2019-04-15 13:46:09 -0500 )edit

No CUDA 10 should work. Did you get the output above in CMake, did you include the contrib repo? The site is up now.

cudawarped gravatar imagecudawarped ( 2019-04-15 14:20:59 -0500 )edit

I don't remember if I got that output, but I will try again now following the guide above. I did include the extra modules. I have never used Anaconda before and I am getting some errors while trying to run CMake but hopefully I can sort it out.

zbadioh gravatar imagezbadioh ( 2019-04-15 15:27:07 -0500 )edit

Sorry I'm new to this forum and I'm not sure how to put a code box. But I got this now:

-- OpenCV modules: -- To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto

I also had the Python part but for python3. I will try building now in VS.

zbadioh gravatar imagezbadioh ( 2019-04-15 15:52:10 -0500 )edit

I built it and got a cv2.cp37-win_amd64.pyd. I placed it into the site-packages folder but I am getting an error while importing: "ImportError: DLL load failed: The specified module could not be found." Do I need to use anaconda python ? Because if I try using the python.exe from Anaconda, the virtual env in PyCharm can not get built.

EDIT: I just installed a window update that was available and after a restart of my PC it worked. Thanks alot!

zbadioh gravatar imagezbadioh ( 2019-04-16 02:37:43 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-04-14 17:14:46 -0500

Seen: 101 times

Last updated: Apr 15