Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindCuda.cmake should use the libcuda.so stub #6577

Closed
flx42 opened this issue May 23, 2016 · 6 comments
Closed

FindCuda.cmake should use the libcuda.so stub #6577

flx42 opened this issue May 23, 2016 · 6 comments

Comments

@flx42
Copy link

flx42 commented May 23, 2016

OpenCV version: master (64a5126)
Host OS: Linux (Ubuntu 14.04), running inside a Docker container.

When compiling OpenCV master with -DBUILD_EXAMPLES=ON on a machine where the CUDA toolkit is installed but no NVIDIA driver is present, the configure step will fail:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_CUDA_LIBRARY (ADVANCED)
    linked by target "example_gpu_alpha_comp" in directory /opencv/samples/gpu
    linked by target "example_gpu_bgfg_segm" in directory /opencv/samples/gpu
    linked by target "example_gpu_cascadeclassifier" in directory /opencv/samples/gpu
    linked by target "example_gpu_cascadeclassifier_nvidia_api" in directory /opencv/samples/gpu
[... all the gpu samples]

This is because libcuda.so is not found.

This problem is in the following macro:
https://github.com/Itseez/opencv/blob/64a5126ff83d576dab72cb67f41a1a1153e0de00/cmake/FindCUDA.cmake#L682-L714
This macro should also look into the stub libraries offered by the CUDA toolkit (/usr/local/cuda/lib64/stubs/).
When cross-compiling you are already using the stubs folder, but the 32-bit version:
https://github.com/Itseez/opencv/blob/64a5126ff83d576dab72cb67f41a1a1153e0de00/cmake/FindCUDA.cmake#L689
We should do the same but with lib64/stubs and then there will be no need of having the CUDA driver installed when simply building OpenCV.

Docker was used because there is no CUDA driver when compiling, but the problem should be the same on a machine with the CUDA toolkit installed but with no CUDA driver. This is my Dockerfile:

FROM nvidia/cuda:7.5-devel                                        

RUN apt-get update && apt-get install -y --no-install-recommends \       
        ca-certificates \                                                
        cmake \                                                          
        git \                                                            
        pkg-config \                                                     
        wget && \                                                        
    rm -rf /var/lib/apt/lists/*                                          

RUN git clone --depth 1 https://github.com/Itseez/opencv.git /opencv && \
    cd /opencv && \                                                      
    cmake -DBUILD_EXAMPLES=ON .                                          
@flx42
Copy link
Author

flx42 commented May 23, 2016

Also, my LIBRARY_PATH variable is set to the stubs folder, but it is ignored by cmake.

@GBJim
Copy link

GBJim commented Jun 17, 2016

Hi, I had the exact same problem.
Is there a solution for this?

@flx42
Copy link
Author

flx42 commented Jun 17, 2016

@GBJim try to add the following to your cmake command:

-DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs

See the doc:
https://cmake.org/cmake/help/v3.3/command/find_library.html

@GBJim
Copy link

GBJim commented Jun 21, 2016

@fix42 Thanks for the help!
I made a symbolic link connecting two locations :)

@vinograd47
Copy link
Contributor

You can explicitly specify CUDA_CUDA_LIBRARY variable in CMake command line:

-DCUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so

@alalek
Copy link
Member

alalek commented Jul 6, 2019

CUDA_CUDA_LIBRARY is selected properly in NVIDIA Docker containers for CUDA development:
https://gitlab.com/nvidia/cuda/blob/7f47169af7e0c7901d17559c37c9a54ce9e8f368/8.0/devel/Dockerfile#L22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants