openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
7.3k stars 2.27k forks source link

[IE] exception Can not init Myriad device: NC_ERROR #1756

Closed mingmingtasd closed 4 years ago

mingmingtasd commented 4 years ago

When we use vpu myriad plugin to loadNetwok() and infer_request->Infer() for more than one time, it throwed that "[IE] exception Can not init Myriad device: NC_ERROR". I tried to setConfig with KEY_VPU_MYRIAD_FORCE_RESET, but still failed. Is it a bug of vpu? Or can you show an example for how to set configurations for vpu to resolve this problem?

brmarkus commented 4 years ago

Can you provide more details about what you mean with "more than one time"? Do you have multiple instances per process, per thread, do you have multiple processes? It's working when you call it only once (one model to load to the VPU and then do inferences)?

OpenVINO/OpenModelZoo has multiple samples where you can specify which device to use when there are multiple models to use; you may want to check e.g. "gaze estimation demo".

Do you try to use a NCS2/Myriad-X? Or an older NCS/Myriad?

mingmingtasd commented 4 years ago

hi, I use NCS2. Yes, it's working when I call it only once (one model to load to the VPU and then do inferences) as below:

std::unique_ptr<InferRequest> infer_request_;
std::unique_ptr<ExecutableNetwork> execution_;
std::unique_ptr<Core> ie_core_;

std::unique_ptr<InferRequest> infer_request;
std::unique_ptr<Core> ie_core;
std::unique_ptr<ExecutableNetwork> execution;

execution.reset(new ExecutableNetwork(
    static_cast<IExecutableNetwork::Ptr&>(ie_core->LoadNetwork(
        *(compilation_->network_), device_name, plugin_Config))));
infer_request.reset(new InferRequest(
    static_cast<IInferRequest::Ptr>(execution->CreateInferRequest())));

infer_request_ = std::move(infer_request);
execution_ = std::move(execution);
ie_core_ = std::move(ie_core);

infer_request->Infer();

After the first inference, I release these objects:

    infer_request_.reset(nullptr);
    execution_.reset(nullptr);
    ie_core_.reset(nullptr);

and load the second different model as the first process. Then sometimes it will throw this error at execution.reset(new ExecutableNetwork( static_cast<IExecutableNetwork::Ptr&>(ie_core->LoadNetwork( *(compilation_->network_), device_name, plugin_Config)))); . Then release these objects and load the third model, it works with no error... Then for fourth model, wrong; for fifth model, right....... It seems to appear alternately.

For other plugins, using the same codes will not report this error.

maxlytkin commented 4 years ago

@mingmingtasd It is possible that your NCS2 device may be already fully occupied by the first instance of your application, so that is most likely the reason why you see NC_ERROR when running the second instance. I don’t think this is the correct usage model to run the same script simultaneously on single NCS2 device. If you want to run multiple networks in parallel for one NCS2 device, please see how the parallelism is implemented with these examples: Multi Camera Multi Target demo - https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/python_demos/multi_camera_multi_target_tracking Action Recognition demo - https://github.com/opencv/open_model_zoo/tree/master/demos/python_demos/action_recognition

mingmingtasd commented 4 years ago

@mingmingtasd It is possible that your NCS2 device may be already fully occupied by the first instance of your application, so that is most likely the reason why you see NC_ERROR when running the second instance. I don’t think this is the correct usage model to run the same script simultaneously on single NCS2 device. If you want to run multiple networks in parallel for one NCS2 device, please see how the parallelism is implemented with these examples: Multi Camera Multi Target demo - https://github.com/openvinotoolkit/open_model_zoo/tree/master/demos/python_demos/multi_camera_multi_target_tracking Action Recognition demo - https://github.com/opencv/open_model_zoo/tree/master/demos/python_demos/action_recognition

Thanks very much! I will look and try.

maxlytkin commented 4 years ago

Closing this case. Please feel free to re-open or start a new issue if additional assistance is needed. Thank you.