Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile OpenCV without GPU?

Tags:

opencv

cmake

gpu

I've just run cmake -D CMAKE_BUILD_TYPE=RELEASE .. from OpenCV/build, and got in my output:

--   OpenCV modules:
--     To be built:                 core imgproc flann highgui features2d calib3d ml video
                                    objdetect contrib nonfree gpu legacy photo python
                                    stitching ts videostab
--     Disabled:                    -
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera java world

The thing is, compilation with gpu fails, maybe because my machine doesn't have one? (It's an EC2 instance).

make fails with an odd error:

Scanning dependencies of target opencv_test_gpu
[ 72%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_gpumat.cpp.o
[ 72%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/utility.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_filters.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_copy_make_border.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/main.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_threshold.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_video.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
make[2]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o] Error 4
make[1]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/all] Error 2
make: *** [all] Error 2

I've tried using the flag -DOPENCV_MODULES_DISABLED_USER="gpu" but that produces weird output with gpu listed as to be built and disabled.

--   OpenCV modules:
--     To be built:                 core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree gpu legacy photo python stitching ts videostab
--     Disabled:                    gpu
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera java world

How do I compile without gpu?

like image 710
fredley Avatar asked Mar 01 '13 15:03

fredley


People also ask

Can OpenCV work without GPU?

By default, there is no need to enable OpenCV with CUDA for GPU processing, but during production, when you have heavy OpenCV manipulations to do on image/video files, we can make use of the OpenCV CUDA library to make those operations to run on GPU rather than CPU and it saves a lot of time.


4 Answers

To disable building a specific module, use

-D BUILD_opencv_{modulename}=OFF

In this case, use

-D BUILD_opencv_gpu=OFF
like image 54
char101 Avatar answered Sep 24 '22 09:09

char101


Try to add -D WITH_CUDA=OFF to your cmake command line.

like image 33
cedrou Avatar answered Sep 23 '22 09:09

cedrou


For OpenCV 2.4.11 on EC2, I had to include both -D BUILD_opencv_gpu=OFF and -D WITH_CUDA=OFF. I also included -D WITH_1394=OFF to avoid a warning in python. So:

cd opencv-2.4.11/
mkdir release
cd release/
cmake -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
like image 22
Mark Woodward Avatar answered Sep 22 '22 09:09

Mark Woodward


This is caused by not having enough memory with your EC2 instance. I got a similar error (different module) with an EC2/Micro running Ubuntu 12.10, but it was smooth sailing on an EC2/Small.

like image 39
Zach Garner Avatar answered Sep 26 '22 09:09

Zach Garner