记录一个问题linux + opencv + gpu视频解码,好不容易编译通过,运行又coredump了
Posted ahfuzhang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记录一个问题linux + opencv + gpu视频解码,好不容易编译通过,运行又coredump了相关的知识,希望对你有一定的参考价值。
1.首先编译了opencv + cuda
编译选项中使用了以下关于cuvid库的内容:
//"nvcuvid" library
CUDA_nvcuvid_LIBRARY:FILEPATH=/usr/local/lib/libnvcuvid.so
//Path to a library.
CUDA_rt_LIBRARY:FILEPATH=/usr/local/cuda-9.0/lib64/libcudart_static.a
//Include NVidia Video Decoding library support
WITH_NVCUVID:BOOL=ON
2.下载了这个opencv + cuvid视频解码例子:
https://github.com/opencv/opencv/blob/master/samples/gpu/video_reader.cpp
编译和链接命令行:
g++ -c video_reader.cpp -o video_reader.o -g -I"/home/admin/opencv/2019-05-09_cuda/include/opencv4/" -std=c++11 g++ -o video_reader video_reader.o -L"/home/admin/opencv/2019-05-09_cuda/lib64/" -lopencv_core -lopencv_videoio -lopencv_cudacodec -lopencv_imgproc -lopencv_imgcodecs -lopencv_flann -lopencv_img_hash -lopencv_photo -L"/usr/local/cuda/lib64/stubs" -lcuda -lcublas -L"/usr/local/cuda/lib64" -lcudart -L"/usr/local/lib/" -lnvcuvid -lz -ldl -lpthread -lopencv_imgcodecs -lopencv_core -lopencv_imgcodecs -L"/home/admin/opencv/2019-05-09_cuda/lib64/opencv4/3rdparty" -lIlmImf -lopencv_core -lopencv_imgproc
3. 运行程序,出现coredump,GPU驱动的版本是 384.81
./video_reader stand_input.mp4
Program received signal SIGSEGV, Segmentation fault.
堆栈信息如下:
(gdb) bt #0 0x00000000007eb4aa in cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource ( this=0x1731810, fname=...) at /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuvid_video_source.cpp:63 #1 0x00000000007e6943 in cv::cudacodec::createVideoReader (filename=...) at /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/video_reader.cpp:206 #2 0x000000000040e0cb in main (argc=2, argv=0x7fffffffe5a8) at video_reader.cpp:33 (gdb) f 0 #0 0x00000000007eb4aa in cv::cudacodec::detail::CuvidVideoSource::CuvidVideoSource ( this=0x1731810, fname=...) at /home/admin/opencv/opencv_contrib-master/modules/cudacodec/src/cuvid_video_source.cpp:63 63 CUresult cuRes = cuvidCreateVideoSource(&videoSource_, fname.c_str(), ¶ms);
4. 搜索了一下,这篇帖子貌似提供了解决办法:
https://github.com/opencv/opencv/issues/10201
‘Segmentation fault‘ with gpu video decoding #10201
下一步尝试自己下载一个 Video_Codec_SDK 库来替换系统自带的版本。
以上是关于记录一个问题linux + opencv + gpu视频解码,好不容易编译通过,运行又coredump了的主要内容,如果未能解决你的问题,请参考以下文章
HYF-Linux8 环境配置躺坑记录 cuda8 cudnn6 virtualenv tensorflow opencv3.3.1