openvinotoolkit / open_model_zoo

Pre-trained Deep Learning models and demos (high quality and extremely fast)
https://docs.openvino.ai/latest/model_zoo.html
Apache License 2.0
4.07k stars 1.36k forks source link

Getting Access violation reading location while reading readFromModelOptimizer OR readNet #860

Closed Bahramudin closed 4 years ago

Bahramudin commented 4 years ago

I installed Intel® OpenVINO™ toolkit 2020 1 version, and from open_model_zoo downloaded the following two files:

person-vehicle-bike-detection-crossroad-0078.bin  
person-vehicle-bike-detection-crossroad-0078.xml 

OpenVINO installed successfully and when running the demos it runs without error. And added all necessary paths to the environment variable e.g:

C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\inference_engine\bin\intel64\Release
C:\Program Files (x86)\IntelSWTools\openvino_2020.1.033\opencv\bin
C:\Program Files (x86)\IntelSWTools\openvino_2020.1.033\deployment_tools\ngraph\lib
C:\Program Files (x86)\IntelSWTools\openvino\inference_engine\external\tbb\bin

And then for test, I first run a simple program which opens (laptop camera as well as a video file) and read frames and shows it:

void main ()
{
    cv::Mat frame;
    cv::VideoCapture capture;
    int type = 0;
    if (type == 0) {
        capture.open("C:/video/768x576.avi");
    }
    else if (type == 1) {
        capture.open(0);
    }

    cv::namedWindow("video", cv::WINDOW_FREERATIO);
    while (capture.read(frame)) {
        imshow("video", frame);
        cv::waitKey((type == 0 ? int(1000 / capture.get(cv::CAP_PROP_FPS)) : 1));
    }
}

All works well. But when I read net, then throws exception, code + error:

        std::string modelName = "person-vehicle-bike-detection-crossroad-0078"; 
        cv::Size size(1024, 1024); 
        string basePath = "C:/models/";
        string xml = basePath + modelName + ".xml";
        string bin = basePath + modelName + ".bin";
        cv::dnn::Net net = cv::dnn::Net::readFromModelOptimizer(xml, bin); // error line
        //cv::dnn::Net net = cv::dnn::readNet(bin, xml); // it is also an error line

Error: Exception thrown at 0x00007FFEBCA412D4 (ntdll.dll) in cloths_detector.exe: 0xC0000005: Access violation reading location 0x0000000000000004.

So I don't know where I am wrong, and how to solve this error? Thanks!

IRDonch commented 4 years ago

I tried this, but I couldn't reproduce it. What's your compiler command line? Can you gather a full stack trace?

Bahramudin commented 4 years ago

@IRDonch Thanks for the reply! I am using Visual Studio 2019. All the stack trace message I got while running program is what I copied above.

alalek commented 4 years ago

https://stackoverflow.com/questions/945193/how-do-i-find-the-stack-trace-in-visual-studio

Bahramudin commented 4 years ago

It is what I got from the stack trace:

Exception thrown at 0x00007FFEB9D5A839 in app.exe: Microsoft C++ exception: InferenceEngine::details::InferenceEngineException at memory location 0x000000611118D580. Exception thrown at 0x00007FFEB9D5A839 in app.exe: Microsoft C++ exception: InferenceEngine::details::InferenceEngineException at memory location 0x000000611118D8F0. 'app.exe' (Win32): Loaded 'C:\Program Files (x86)\IntelSWTools\openvino_2020.1.033\deployment_tools\inference_engine\bin\intel64\Release\GNAPlugin.dll'. Module was built without symbols. 'app.exe' (Win32): Loaded 'C:\Program Files (x86)\IntelSWTools\openvino_2020.1.033\deployment_tools\inference_engine\bin\intel64\Release\gna.dll'. 'app.exe' (Win32): Loaded 'C:\Windows\System32\setupapi.dll'. 'app.exe' (Win32): Loaded 'C:\Windows\System32\devobj.dll'. Exception thrown at 0x00007FFEBCA412D4 (ntdll.dll) in app.exe: 0xC0000005: Access violation reading location 0x0000000000000004.

alalek commented 4 years ago

These lines are NOT from stack trace (call stack) window.

It should look like this (but for C++ instead of C#).

Bahramudin commented 4 years ago

Hmm, see this now: image

Bahramudin commented 4 years ago

Latest changes: I build OpenCV from source with enabling EI, now the line above is not throwing the error, but this line throws an exception: cv::Mat detection = net.forward();

Why it passed the first error, and now why it throws the second error?

alalek commented 4 years ago

Try this:

or reinstall OpenVINO without GNA plugin (disable GNA component in installer).


Which CPU model do you have? (link on ark.intel.com is preferable)

Bahramudin commented 4 years ago

For the above (readFromModelOptimizer OR readNet) problem more stack trace info: here I am unable to copy/paste the text, so using screenshots image

image

Bahramudin commented 4 years ago

@alalek Thank you so much!! Yes, it was the tick, now it works well, with both release and debugs mode, but in debug mode, it works very slow. And also now it works well with the OpenCV which builds by myself.

In the next release, it will be good to avoid this problem exist.

Thanks again!!