I'm having unit tests using interop calls on dlls using opencv and cuda.
Unit tests (using the Microsoft framework in VS 2017 enterprise) are failing because cuda calls in opencv are not thread safe or more likely multiprocess safe. Switching to parallel or non parallel tests won't help; only when I run tests individually (right click, run test) tests are succeeding.
How can I make my unit tests thread safe ? Or rather multi process safe ?
In the native code, I'm releasing the cuda resources at the end of function calls. And made the code thread safe, but it seems that making it multiprocess safe is what is required.
I tried to use a combination of private static object _lockObj = new object()
and lock(_obj) { //cuda-interop calls }
but this won't improve the results.
The kind of output when a test fails:
in managed part:
System.Runtime.InteropServices.SEHException: 'Problem with native part: <External component has thrown an exception.> Error code: 0x80004005 | Name: E_FAIL | Description: Unspecified failure'
in native part:
opencv exception :OpenCV(4.0.1-dev) I:\opencv-master\opencv_contrib\modules\cudaoptflow\src\brox.cpp:124: error: (-217:Gpu API call) NCV Assertion Failed: cudaError_t=77, file=I:/opencv-master/opencv_contrib/modules/cudalegacy/src/cuda/NCVBroxOpticalFlow.cu, line=1017 in function 'anonymous-namespace::outputHandler'
User contributions licensed under CC BY-SA 3.0