1. 发现问题
在使用 sanitizer
调试引用了带 cuda
编译的 opencv
程序内存错误的时候,遇到了必现的 (-217:Gpu API call) out of memory
错误,导致程序直接无法启动,具体错误如下:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.2.0) /home/lsd/libs/opencv-4.2.0_cuda/modules/core/src/cuda_stream.cpp:303: error: (-217:Gpu API call) out of memory in function 'Impl'
2. 解决问题
根据参考链接中 github 的讨论,出问题的原因应该是 sanitizer
和 cuda
以某种方式发生了冲突,使用在命令前添加 ASAN_OPTIONS
的方法可以绕过此问题:
ASAN_OPTIONS=protect_shadow_gap=0 原运行程序的命令
3. 参考链接
- asan: problem calling NVIDIA CUDA libraries: https://github.com/google/sanitizers/issues/629
- c++使用sanitizer代码分析: https://blog.csdn.net/qq_37868450/article/details/118766735