I have installed CUDA 8.0 on ubuntu and set the environment variable in .bashrc as below:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:/usr/local/cuda/bin
Also, when I run
nvcc --version
I can find the correct version of CUDA.
However, it always shows "use cuda: NO" when I try to run "cmake .." inside opencv 3.3 directory.
Can anyone solve this problem? Thanks.
ps:
1. When I compile caffe, cmake can find CUDA correctly. It gets more confusing.
2. When I check OpenCVDetectCUDA.cmake, I found the following phrase sentence:
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
return()
endif()
Then I comment this paragraph, cmake can find CUDA. I am not sure what effect it will cause in later compilation and use.
If building from source is giving you as issue try installing via pip:
$ pip install opencv-python
I suspect the reason why you are having issues with building your opencv is because of the source of your files.
Related
I have CUDA 10.1. I'm trying to build opencv4 using CUDA and CUDNN support.When i run make command i get the following error
/usr/bin/ld: cannot find -llib64 while trying to link with libopencv_cudev.so.
My cmake command is as follows:
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DINSTALL_PYTHON_EXAMPLES=ON -DINSTALL_C_EXAMPLES=ON -DOPENCV_ENABLE_NONFREE=ON -DWITH_CUDA=ON -DWITH_CUDNN=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.1 -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DPYTHON_EXECUTABLE=/usr/bin/python3 -DBUILD_EXAMPLES=ON ..
My nvidia cuda toolkit version is: release 7.5, V7.5.17.
What might be the error? Please guide.
EDIT
I installed CUDA using this link. But that did not install nvcc. So i installed nvcc using terminal command line sudo apt install nvidia-cuda-toolkit. Is it not the correct way.
I am trying to build this code:
https://docs.opencv.org/3.2.0/d5/d6f/tutorial_feature_flann_matcher.html
I am using Ubuntu 16.04 with CLion 2017.3 and have OpenCV 3.4 installed.
xfeatures2d.hpp can't be found on the system.
I have looked at many different problems on the internet, but couldn't find a solution.
Any help?
You have to include cmake comiplation flag to opencv OPENCV_EXTRA_MODULES_PATH and set it to the opencv_contrib/modules.
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules
Here's what I had to do to compile OpenCV with xfeatures2d:
Download opencv_contrib (I took a release from the releases page). This step is what gives us xfeatures2d.
Unpack the tarball somewhere, e.g., ~/src/opencv_contrib-4.5.5
When configuring OpenCV (the main OpenCV source like opencv-4.5.2) with CMake, add the following option to cmake command line (adjusting the value to be your actual path to the modules subdirectory of the opencv_contrib tarball):
-DOPENCV_EXTRA_MODULES_PATH=$HOME/src/opencv_contrib-4.5.5/modules/
Now just build as you normally would and install.
The above actions gave me the expected file (among others): /usr/include/opencv4/opencv2/xfeatures2d.hpp.
I am trying to build opencv for CARMA. I want to build it with GTK support but cmake not find gtk. i have installed gtk. i Debug the cmake and found that it not find pkg-config executable how i can solve this issue?
So i am running ubuntu 13.04 on the sd card of my new beaglebone black. I am attempting to install opencv-2.4.2. I've got everything installed without errors but when i try to build and run a program
g++ 'pkg-config opencv --cflags' FILE.cpp -o FILE 'pkg-config opencv --libs'
I get the error:
pkg-config opencv --cflags: no such file or directory
pkg-config opencv --libs: no such file or directory
When I run pkg-config --libs opencv it gives me the correct directory (/usr/lib/ .so) with all my libraries and I have confirmed they are all actually there. pkg-config opencv --cflags gives -I/usr/include/opencv. Which also exists.
I have edited my bash.bashrc, opencv.pc, and opencv.conf files reflect these paths. They were /usr/local/lib but no libraries installed there.
I'm running out of ideas guys, any help or suggestions would be great.
Thanks.
you should be using backticks (`) instead of ' to substitute the output of pkg-config into the command line.
opencv-2.4.2 is provided in the angstrom distribution that comes with the BeagleBone Black. One problem I found was that python-opencv is at 2.3 with angstrom, so if you want to do your development work in python you have to downgrade opencv to 2.3.
I am compiling a dependency for a project on Ubuntu 10.10, and instead of having it install to /usr/local by default, I am instead installing it to /tmp/stage/usr/local. How do I go about informing CMake of the location of this custom installed dependency when I call it to generate the build files for said project.
I am running CMake 2.8.1, and I have tried to set CMAKE_PREFIX_PATH on the cmake command line, like so
cmake -D CMAKE_PREFIX_PATH=/tmp/stage/usr/local
but this doesn't seem to make a difference - the project doesn't seem to detect the dependency.
Also, if it matters, the project in question is OpenCV 2.2, and the dependency in question is FFMPEG...
I figured out how to fix my problem, and trying to point CMake at the appropriate install location isn't the issue.
Apparently, CMake is unable to find the pkg-config files for FFMPEG (i.e. libavcodec.pc, libavdevice.pc, etc.) that tell it where the FFMPEG headers and libraries are located. In a typical install scenario, these files would be located at /usr/lib/pkgconfig. However because of the custom install location, they are instead located at /tmp/stage/usr/local/lib/pkgconfig.
So that CMake could find these files, I had to add the following environment variable:
export PKG_CONFIG_PATH=/tmp/stage/usr/local/lib/pkgconfig
After which point, OpenCV built against FFMPEG as expected.