Skip to content

cv2.cudacodec.createVideoReader(x2_rma.mp4) #3920

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

Open
apurvathakkar-nextgen opened this issue Apr 8, 2025 · 2 comments
Open

cv2.cudacodec.createVideoReader(x2_rma.mp4) #3920

apurvathakkar-nextgen opened this issue Apr 8, 2025 · 2 comments

Comments

@apurvathakkar-nextgen
Copy link

Traceback (most recent call last):
File "/home/ubuntu/apurva.thakkar/video_analysis/debug.py", line 39, in
process_video_with_gpu(video_path)
File "/home/ubuntu/apurva.thakkar/video_analysis/debug.py", line 13, in process_video_with_gpu
cap = cv2.cudacodec.createVideoReader(video_path)
cv2.error: OpenCV(4.12.0-dev) /home/ubuntu/opencv/modules/core/include/opencv2/core/private.cuda.hpp:112: error: (-213:The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

This is my code
import cv2
import time
import subprocess

Function to check GPU usage

def check_gpu_usage():
# Run nvidia-smi and capture output
result = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE)
print(result.stdout.decode())

def process_video_with_gpu(video_path):
# Use the GPU decoder
cap = cv2.cudacodec.createVideoReader(video_path)
fps = cap.get(cv2.CAP_PROP_FPS)

frame_count = 0
total_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)

while True:
    ret, frame = cap.read()
    if not ret:
        break
    
    # Process the frame (for now, just print frame count)
    frame_count += 1
    print(f"Processing frame {frame_count}/{total_frames}")
    
    # Check GPU usage after processing each frame
    if frame_count % 10 == 0:  # Check every 10 frames
        check_gpu_usage()
    
    time.sleep(0.1)  

cap.release()

Run the test

if name == "main":
video_path = 'x2_rma.mp4'
process_video_with_gpu(video_path)

@apurvathakkar-nextgen
Copy link
Author

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_EXAMPLES=ON -D WITH_CUDA=ON -D CUDA_ARCH_BIN=7.5 -D CUDA_ARCH_PTX= -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D BUILD_opencv_world=ON -D BUILD_opencv_python3=ON -D PYTHON3_EXECUTABLE=$(which python3) ..

@apurvathakkar-nextgen
Copy link
Author

/video_analysis# python3 -c "import cv2; print(cv2.getBuildInformation())"

General configuration for OpenCV 4.12.0-dev =====================================
Version control: 4.11.0-321-g1b3db545a3

Extra modules:
Location (extra): /home/ubuntu/opencv_contrib/modules
Version control (extra): 4.11.0-30-g1fffe354

Platform:
Timestamp: 2025-04-07T22:10:10Z
Host: Linux 6.8.0-1024-aws x86_64
CMake: 4.0.0
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/gmake
Configuration: Release
Algorithm Hint: ALGO_HINT_ACCURATE

CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (19 files): + SSSE3 SSE4_1
SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
AVX (10 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16
AVX2 (39 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3
AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3 AVX_512F AVX512_COMMON AVX512_SKX

C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 11.4.0)
C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-12.4/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/local/cuda-12.4/lib
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 dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape signal stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
Disabled: -
Disabled by dependency: -
Unavailable: alphamat cannops cvv fastcv java julia matlab ovis python2 python2 sfm viz
Applications: tests perf_tests examples apps
Documentation: NO
Non-free algorithms: NO

GUI:
GTK+: YES (ver 2.24.33)
GtkGlExt: NO
VTK support: NO

Media I/O:
ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
WEBP: build (ver decoder: 0x0209, encoder: 0x020f, demux: 0x0107)
AVIF: NO
PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.3.0)
JPEG 2000: build (ver 2.5.3)
OpenEXR: /usr/lib/x86_64-linux-gnu/libImath-2_5.so /usr/lib/x86_64-linux-gnu/libIlmImf-2_5.so /usr/lib/x86_64-linux-gnu/libIex-2_5.so /usr/lib/x86_64-linux-gnu/libHalf-2_5.so /usr/lib/x86_64-linux-gnu/libIlmThread-2_5.so (ver 2.5.7)
GIF: NO
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES

Video I/O:
FFMPEG: YES
avcodec: YES (58.134.100)
avformat: YES (58.76.100)
avutil: YES (56.70.100)
swscale: YES (5.9.100)
avresample: NO
GStreamer: NO
v4l/v4l2: YES (linux/videodev2.h)

Parallel framework: pthreads

Trace: YES (with Intel ITT(3.25.4))

Other third-party libraries:
Intel IPP: 2022.0.0 [2022.0.0]
at: /home/ubuntu/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
Intel IPP IW: sources (2022.0.0)
at: /home/ubuntu/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
VA: NO
Lapack: NO
Eigen: NO
Custom HAL: YES (ipp (ver 0.0.1))
Protobuf: build (3.19.1)
Flatbuffers: builtin/3rdparty (23.5.9)

NVIDIA CUDA: YES (ver 12.4, CUFFT CUBLAS)
NVIDIA GPU arch: 75
NVIDIA PTX archs:

cuDNN: YES (ver 8.9.7)

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

Python 3:
Interpreter: /usr/bin/python3 (ver 3.10.12)
Libraries: /usr/lib/x86_64-linux-gnu/libpython3.10.so (ver 3.10.12)
Limited API: NO
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.21.5)
install path: lib/python3.10/dist-packages/cv2/python-3.10

Python (for build): /usr/bin/python3

Java:
ant: NO
Java: YES (ver 11.0.26)
JNI: NO
Java wrappers: NO
Java tests: NO

Install to: /usr/local

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

No branches or pull requests

1 participant