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

Build opencv in Docker throw no cuda error when calling cv::cudacodec::createVideoReader #17649

Closed
PistonY opened this issue Jun 24, 2020 · 14 comments
Labels
category: build/install category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib invalid question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org

Comments

@PistonY
Copy link

PistonY commented Jun 24, 2020

Hi, I build opencv with cuda and BUILD_opencv_cudacodec, but when I use

cv::cudacodec::createVideoReader

I got an error

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.3.0) /opencv-4.3.0/modules/core/include/opencv2/core/private.cuda.hpp:115: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

I use opencv 4.3.0 (latest)
CUDA 10.2
CUDNN 7.6

Here is my calling std:: cout << cv::getBuildInformation() << std::endl; results

General configuration for OpenCV 4.3.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /opencv_contrib-4.3.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2020-06-12T04:59:23Z
    Host:                        Linux 5.3.0-53-generic x86_64
    CMake:                       3.10.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (16 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (5 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++ standard:                11
    C++ Compiler:                /usr/bin/c++  (ver 7.4.0)
    C++ flags (Release):         -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-10.2/lib64 -L/usr/lib/x86_64-linux-gnu
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    dnn world
    Disabled by dependency:      dnn_objdetect dnn_superres text
    Unavailable:                 alphamat cnn_3dobj cvv hdf java js matlab ovis python2 python3 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  GUI: 
    GTK+:                        YES (ver 2.24.32)
      GThread :                  YES (ver 2.56.4)
      GtkGlExt:                  NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.4-62)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build Jasper (ver 1.900.1)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      YES (2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (57.107.100)
      avformat:                  YES (57.83.100)
      avutil:                    YES (55.78.100)
      swscale:                   YES (4.8.100)
      avresample:                NO
    GStreamer:                   NO
    v4l/v4l2:                    YES (linux/videodev2.h)

  Parallel framework:            OpenMP

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   /opencv-4.3.0/build/3rdparty/ippicv/ippicv_lnx/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                /opencv-4.3.0/build/3rdparty/ippicv/ippicv_lnx/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS)
    NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
    NVIDIA PTX archs:

  cuDNN:                         YES (ver 7.6.5)

  OpenCL:                        YES (no extra features)
    Include path:                /opencv-4.3.0/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            /usr/bin/python2.7

  Java:                          
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    /usr/local

And the full Dockerfile define as below

FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04
MAINTAINER Devin Yang <pistonyang@gmail.com>
WORKDIR /
COPY . .
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak \
    && mv sources.list /etc/apt/ \
    && rm /etc/apt/sources.list.d/cuda.list \
    && rm /etc/apt/sources.list.d/nvidia-ml.list \
    && apt-get update
RUN apt-get install -y \
    cmake \
    clang \
    git \
    unzip \
    build-essential \
    libgtk2.0-dev \
    pkg-config \
    libavcodec-dev \
    libavformat-dev \
    libswscale-dev \
    mesa-common-dev \
    libtbb2 \
    libtbb-dev \
    libjpeg-dev \
    libpng-dev \
    libtiff-dev \
    libdc1394-22-dev \
    && apt-get autoclean \
    && rm -rf /var/lib/apt/lists/* /var/log/dpkg.log
ENV OPENCV_VERSION="4.3.0"
RUN unzip /opencv-${OPENCV_VERSION}.zip \
    && unzip /opencv_contrib-${OPENCV_VERSION}.zip \
    && unzip /Video_Codec_SDK_9.1.23.zip \
    && mkdir /opencv-${OPENCV_VERSION}/build \
    && cd /opencv-${OPENCV_VERSION}/build \
    && cp /Video_Codec_SDK_9.1.23/include/cuviddec.h /usr/include \
    && cp /Video_Codec_SDK_9.1.23/include/nvcuvid.h /usr/include \
    && cmake -D CMAKE_BUILD_TYPE=Release \
        -D ENABLE_CXX11=1 \
        -D WITH_IPP=ON \
        -D WITH_WEBP=OFF \
        -D BUILD_opencv_python3=no \
        -D BUILD_opencv_python2=no \
        -D WITH_QT=OFF \
        -D OPENCV_FORCE_3RDPARTY_BUILD=ON \
        -D WITH_CUDA=ON \
        -D BUILD_opencv_dnn=OFF \
        -D WITH_NVCUVID=ON \
        -D WITH_OPENMP=ON \
        -D INSTALL_TESTS=ON \
        -D ENABLE_FAST_MATH=ON \
        -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib-4.3.0/modules \
        -D WITH_EIGEN=yes \
        -D WITH_CUDNN=yes \
        -D BUILD_opencv_cudacodec=yes \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        .. \
    && make -j6 \
    && make install
RUN rm /opencv-${OPENCV_VERSION}.zip \
    && rm /opencv_contrib-${OPENCV_VERSION}.zip \
    && rm /Video_Codec_SDK_9.1.23.zip \
    && rm -r /opencv-${OPENCV_VERSION} \
    && rm -r /opencv_contrib-${OPENCV_VERSION} \
    && rm -r /Video_Codec_SDK_9.1.23

I make sure I can see CUDA device in docker container.The results of nvidia-smi and nvcc -v are all right.

@PistonY
Copy link
Author

PistonY commented Jun 24, 2020

I don't know what I missing in docker, it works in origin Ubuntu18.04.

@PistonY
Copy link
Author

PistonY commented Jun 28, 2020

I think I found the issue, I set -D WITH_NVCUVID=ON but finally not build with nvcvid NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS) I don't know why this setting not work..and no error when building.

@PistonY PistonY closed this as completed Jun 29, 2020
@bml1g12
Copy link

bml1g12 commented Oct 30, 2020

@PistonY I would be very grateful if you could share the repo associated and the working dockerfile- I am also struggling with this issue (e.g. sources.list)

@PistonY
Copy link
Author

PistonY commented Oct 30, 2020

@bml1g12 Hi, this is not a Dockerfile issue, if you want to use nvcuvid you need to copy nvcuvid.h from you system to Docker container, this file is provided by Nvidia Driver but it's not expose in Nvidia Docker.

@PistonY
Copy link
Author

PistonY commented Oct 30, 2020

errr...This sources.list is no different, I'm in China so I change it to a China mirror server, If you met Nvidia error when run apt update just remove cuda.list and nvidia-ml.list like me.

@bml1g12
Copy link

bml1g12 commented Oct 30, 2020

@PistonY Thanks for your response. So you managed to get the cudacodec.VideoWriter and cudacodec.VideoReader working?

I've been experimenting here https://github.com/bml1g12/cudacodec_docker_opencv

When I compile the Dockerfile you listed, with three changes:

  • WITH_NVCUVID = OFF - this is what you found is needed to make it build?
  • Cuda 10.1 rather than 10.2
  • Default sources

Source: https://github.com/bml1g12/cudacodec_docker_opencv/blob/master/Dockerfile

when I compile and run videowrite.cpp in that repo, I get:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.3.0) /opencv-4.3.0/modules/core/include/opencv2/core/private.cuda.hpp:115: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

Are you saying I should try:

WITH_NVCUVID = ON?

I did try this with this Dockerfile (https://github.com/bml1g12/cudacodec_docker_opencv/blob/master/Dockerfile_2) but got the same error.

As part of the install, like you did, I include
Video_Codec_SDK_9.1.23.zip in the root, and I notice that this has /include/nvcuvid.h that you refer to, so I think it is already available inside the container.

@PistonY
Copy link
Author

PistonY commented Oct 30, 2020

Yes,
First you need to copy you system nvcuvid.h to Docker,
And then build opencv with WITH_NVCUVID = ON, only if find nvcuvid.h opencv build with Nvcuvid.

@bml1g12
Copy link

bml1g12 commented Oct 30, 2020

Interesting - where should it be copied into such that opencv can find it? If I put it into the root, I expect opencv has no way of finding it? (and its already present inside the Video_Codec_SDK_9.1.23.zip which is being unzipped)

@PistonY
Copy link
Author

PistonY commented Oct 30, 2020

And No not nvcuvid.h in Video_Codec_SDK_9.1.23.zip, I forget the path but you system already have this file (nvcuvid.h).
The file in Video_Codec_SDK_9.1.23.zip won't help.

@PistonY
Copy link
Author

PistonY commented Oct 30, 2020

The path is usr/include.

@bml1g12
Copy link

bml1g12 commented Nov 2, 2020

@PistonY Thanks you for this information; but it seems in CUDA 9+ this file no longer is installed to the system NVIDIA/NvPipe#12 (comment) (I am using CUDA 10.1)

They say on that issue that its been replaced by dynlink_nvcuvid.h but I cant find that I have this either :/

I can see in your Dockerfile (the same one I have tried), you copy it from the Video Codec SDK here: https://github.com/bml1g12/cudacodec_docker_opencv/blob/5023d2623bd9d219dd3cb88b8be41dacdcbc0ac7/Dockerfile#L38

@PistonY
Copy link
Author

PistonY commented Nov 2, 2020

Well..Can you have a try compile opencv outside docker? Does cv::cudacodec::createVideoReader work well?
If you could run that code successfully, you system should have that file because cv::cudacodec::createVideoReader need this.

And the link you show me, I copy it to that path because it could make me compile with WITH_NVCUVID = ON successfully, you should still got an error when calling cv::cudacodec::createVideoReader.

Try this path: /usr/local/cuda/include/nvcuvid.h

@bml1g12
Copy link

bml1g12 commented Nov 2, 2020

When compiling on my local machine with a slightly different built I had the same problem. I will try again today, using exactly the same commands as the dockerfile on my local machine.

To clarify, I can compile opencv without errors using the Dockerfule, but after compiling and running this demo: https://github.com/bml1g12/cudacodec_docker_opencv/blob/master/videowrite.cpp

I get:

root@64ac2385fd36:/# ./videowrite 
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.3.0) /opencv-4.3.0/modules/core/include/opencv2/core/private.cuda.hpp:115: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

I do not have this file on my host machine:

╰─❯ ls /usr/local/cuda/include/nvcuvid.h
ls: cannot access '/usr/local/cuda/include/nvcuvid.h': No such file or directory

@GalSang17
Copy link

GalSang17 commented Feb 6, 2024

Hi, I build opencv with cuda and BUILD_opencv_cudacodec, but when I use

cv::cudacodec::createVideoReader

I got an error

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.3.0) /opencv-4.3.0/modules/core/include/opencv2/core/private.cuda.hpp:115: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

I use opencv 4.3.0 (latest) CUDA 10.2 CUDNN 7.6

Here is my calling std:: cout << cv::getBuildInformation() << std::endl; results

General configuration for OpenCV 4.3.0 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /opencv_contrib-4.3.0/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2020-06-12T04:59:23Z
    Host:                        Linux 5.3.0-53-generic x86_64
    CMake:                       3.10.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (16 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (4 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (5 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?:      YES
    C++ standard:                11
    C++ Compiler:                /usr/bin/c++  (ver 7.4.0)
    C++ flags (Release):         -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-10.2/lib64 -L/usr/lib/x86_64-linux-gnu
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    dnn world
    Disabled by dependency:      dnn_objdetect dnn_superres text
    Unavailable:                 alphamat cnn_3dobj cvv hdf java js matlab ovis python2 python3 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  GUI: 
    GTK+:                        YES (ver 2.24.32)
      GThread :                  YES (ver 2.56.4)
      GtkGlExt:                  NO
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.0.4-62)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.0.10)
    JPEG 2000:                   build Jasper (ver 1.900.1)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      YES (2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (57.107.100)
      avformat:                  YES (57.83.100)
      avutil:                    YES (55.78.100)
      swscale:                   YES (4.8.100)
      avresample:                NO
    GStreamer:                   NO
    v4l/v4l2:                    YES (linux/videodev2.h)

  Parallel framework:            OpenMP

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   /opencv-4.3.0/build/3rdparty/ippicv/ippicv_lnx/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                /opencv-4.3.0/build/3rdparty/ippicv/ippicv_lnx/iw
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS)
    NVIDIA GPU arch:             30 35 37 50 52 60 61 70 75
    NVIDIA PTX archs:

  cuDNN:                         YES (ver 7.6.5)

  OpenCL:                        YES (no extra features)
    Include path:                /opencv-4.3.0/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            /usr/bin/python2.7

  Java:                          
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    /usr/local

And the full Dockerfile define as below

FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04
MAINTAINER Devin Yang <pistonyang@gmail.com>
WORKDIR /
COPY . .
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak \
    && mv sources.list /etc/apt/ \
    && rm /etc/apt/sources.list.d/cuda.list \
    && rm /etc/apt/sources.list.d/nvidia-ml.list \
    && apt-get update
RUN apt-get install -y \
    cmake \
    clang \
    git \
    unzip \
    build-essential \
    libgtk2.0-dev \
    pkg-config \
    libavcodec-dev \
    libavformat-dev \
    libswscale-dev \
    mesa-common-dev \
    libtbb2 \
    libtbb-dev \
    libjpeg-dev \
    libpng-dev \
    libtiff-dev \
    libdc1394-22-dev \
    && apt-get autoclean \
    && rm -rf /var/lib/apt/lists/* /var/log/dpkg.log
ENV OPENCV_VERSION="4.3.0"
RUN unzip /opencv-${OPENCV_VERSION}.zip \
    && unzip /opencv_contrib-${OPENCV_VERSION}.zip \
    && unzip /Video_Codec_SDK_9.1.23.zip \
    && mkdir /opencv-${OPENCV_VERSION}/build \
    && cd /opencv-${OPENCV_VERSION}/build \
    && cp /Video_Codec_SDK_9.1.23/include/cuviddec.h /usr/include \
    && cp /Video_Codec_SDK_9.1.23/include/nvcuvid.h /usr/include \
    && cmake -D CMAKE_BUILD_TYPE=Release \
        -D ENABLE_CXX11=1 \
        -D WITH_IPP=ON \
        -D WITH_WEBP=OFF \
        -D BUILD_opencv_python3=no \
        -D BUILD_opencv_python2=no \
        -D WITH_QT=OFF \
        -D OPENCV_FORCE_3RDPARTY_BUILD=ON \
        -D WITH_CUDA=ON \
        -D BUILD_opencv_dnn=OFF \
        -D WITH_NVCUVID=ON \
        -D WITH_OPENMP=ON \
        -D INSTALL_TESTS=ON \
        -D ENABLE_FAST_MATH=ON \
        -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib-4.3.0/modules \
        -D WITH_EIGEN=yes \
        -D WITH_CUDNN=yes \
        -D BUILD_opencv_cudacodec=yes \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        .. \
    && make -j6 \
    && make install
RUN rm /opencv-${OPENCV_VERSION}.zip \
    && rm /opencv_contrib-${OPENCV_VERSION}.zip \
    && rm /Video_Codec_SDK_9.1.23.zip \
    && rm -r /opencv-${OPENCV_VERSION} \
    && rm -r /opencv_contrib-${OPENCV_VERSION} \
    && rm -r /Video_Codec_SDK_9.1.23

I make sure I can see CUDA device in docker container.The results of nvidia-smi and nvcc -v are all right.

你现在在Docker中编译成功可以使用nvcuvid进行解码了吗,并且支持所有的GPU计算架构,可以告诉下你是怎么处理的吗?谢谢啦@PistonY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build/install category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib invalid question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org
Projects
None yet
Development

No branches or pull requests

4 participants