简体   繁体   English

OpenCV cmake 在为 Docker 构建映像时找不到 CUDA

[英]OpenCV cmake can't find CUDA while building image for Docker

I'm trying to build a docker image with the latest opencv version 4.1.0 to be able to use cudafeatures2D.我正在尝试使用最新的 opencv 4.1.0 版构建一个 docker 映像,以便能够使用 cudafeatures2D。 I have cuda 9.0 installed but every time i try to compile opencv from source it says it doesn't find CUDA.我安装了 cuda 9.0,但每次我尝试从源代码编译 opencv 时,它都说找不到 CUDA。

I'm using the build runtime image FROM nvidia/cuda:9.0-cudnn7-runtime.我正在使用来自 nvidia/cuda:9.0-cudnn7-runtime 的构建运行时映像。 And i've checked in my current image the location of CUDA, /usr/local/cuda-9.0 .我已经在我当前的图像中检查了 CUDA 的位置, /usr/local/cuda-9.0

This is the code I'm using to install:这是我用来安装的代码:

ENV PATH=$PATH:/usr/local/cuda/bin:$PATH
ENV LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
RUN ldconfig

RUN wget https://github.com/opencv/opencv/archive/4.1.0.tar.gz && tar xf 4.1.0.tar.gz && rm 4.1.0.tar.gz
RUN wget https://github.com/opencv/opencv_contrib/archive/4.1.0.tar.gz  && tar xf 4.1.0.tar.gz && rm 4.1.0.tar.gz
RUN cd opencv-4.1.0/ && mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_CUBLAS=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D PYTHON2_EXECUTABLE=/usr/bin/python2.7 -D PYTHON_INCLUDE_DIR=/usr/include/python2.7/ -D PYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python2.7/ -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so -D PYTHON2_NUMPY_INCLUDE_DIRS=/usr/local/lib/python2.7/dist-packages/numpy/core/include/  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules/ -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0 -D CUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so -D CUDA_VERBOSE_BUILD=ON .. && make -j$(nproc) && make install

But I always get this error:但我总是收到这个错误:

-- at: /app/opencv-3.4.6/build/3rdparty/ippicv/ippicv_lnx/iw
CMake Warning at cmake/OpenCVFindLibsPerf.cmake:35 (message):
  OpenCV is not able to find/configure CUDA SDK (required by WITH_CUDA).

  CUDA support will be disabled in OpenCV build.

  To eliminate this warning remove WITH_CUDA=ON CMake configuration option.

Call Stack (most recent call first):
  CMakeLists.txt:794 (include)

finally someone from the opencv repository pointed out that the problem I was having was due to the image I was using:最后有人从 opencv 存储库指出我遇到的问题是由于我使用的图像:

FROM nvidia/cuda:9.0-cudnn7-runtime从 nvidia/cuda:9.0-cudnn7-runtime

The runtime version usually doesn't contain the SDK files, the fix was to change -runtime for -develop.运行时版本通常不包含 SDK 文件,修复方法是将 -runtime 更改为 -develop。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM