I encounter a problem with OpenCV that I have for several days now : it segfaults when calling the cv2.VideoCapture() function.
When launching my script (with GDB) :
extract-all_1 | Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
extract-all_1 | 0x00007f83857fe33b in bool pyopencv_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(_object*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, ArgInfo const&) [clone .isra.1286] ()
extract-all_1 | from /usr/lib/python3/dist-packages/cv2/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so
extract-all_1 | (gdb) quit
When running my script without GDB, the container exits with code 139
I identified the problem occures when calling the "cv2.VideoCapture()" function :
def perform_video_extraction(video_path):
input_movie = cv2.VideoCapture(video_path)
nb_total_frames = int(input_movie.get(cv2.CAP_PROP_FRAME_COUNT))
[...]
Hints :
- I process MP4 video files
- I've tried compressing my videos that are >30fps to 25fps
- I've tried with OpenCV 3.4.9, 4.1.0, 4.1.1, 4.1.2, 4.2.0 and 4.3.0 (pip install)
- I've tried compiling OpenCV 4.2.0 and 4.3.0 from source
- I've tried each version above successively with CUDA 10.0, 10.1 and 10.2 : each version for each case produces the same error
- This segfault is not reproduced when using the CPU (non-cuda) version of OpenCV
Here is my Dockerfile (CUDA 10.2 with OpenCV 4.2.0 built from source) : https://pastebin.com/raw/a42wtcRG
Here is what the cmake summary build returns : https://pastebin.com/raw/SFPUakyL
My config :
- Ubuntu 18.04
- Nvidia Docker (CUDA 10.2, CUDNN 7, Ubuntu 18.04, devel)
- Python 3.6
Have you any recommendation for debugging this problem ?
Thank you