Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.
5960 Discussions

Error when creating and destroying device several times from the same process

Community Manager
Hi all, We are working on a gstreamer pluging that supports inference with the NCS. We want to stop and destroy the device when the pipeline changes state to "Stoped", and create and open the device again when the state is set to "Playing". The problem is that these operations are called from the same process and the NCSDK C API has an unusual behavior with this case. You can see what I'm talking about in the following example: <pre class="code"> ncDeviceCreate(0, &device_handle); for(i = 1; i < 16; i++) { ncDeviceOpen(device_handle); ncDeviceClose(device_handle); printf ("CHECKPOINT #%d: %s:%s:%d\n", i, __FILE__, __FUNCTION__, __LINE__); } </pre> This code fails on the 16th call to ncDeviceOpen. I think this is caused because the "index" variable on the API increments with each call, and there is a limit set to 16 on xLink. If the API exposed some way to reset this index the code would not fail. <pre class="code"> for(i = 1; i < 16; i++) { ncDeviceCreate(0, &device_handle); ncDeviceOpen(device_handle); ncDeviceClose(device_handle); ncDeviceDestroy (&device_handle); printf ("CHECKPOINT #%d: %s:%s:%d\n", i, __FILE__, __FUNCTION__, __LINE__); } </pre> This other code also fails, because it tries to open a new device on every iteration. What I really want is to open and close the same device over and over again. I can see that the C API has a function named resetAll that is called on the first ncDeviceCreate. If this function was exposed or there was a way to call ncDeviceCreate with reset, It would solve my problem. Is there other way to solve this problem? We are using NCSDK-2.05 with the NCS 1. Thank you, -Miguel.
0 Kudos
1 Reply
Community Manager

Hi @miguel.taylor


I have not tried this myself, do you see the same behavior when using the ncsdk version 2.08?