microsoft / CNTK

Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit
https://docs.microsoft.com/cognitive-toolkit/
Other
17.5k stars 4.29k forks source link

CNTK C++ - Slow Evaluation in Debug Mode and Incorrect Result. #2329

Closed darkoob12 closed 6 years ago

darkoob12 commented 7 years ago

I am using CNTK C++ API for License Plate Detection. My problem is that the code does not work in debug mode and it is very slow. Here is my setup:

cv::Mat AECropper::GetMask(cv::Mat img) {
    // pre-process and resize
    cv::Mat img_pp = Preprocess(img);

    // create network input from the image
    ValuePtr inVal;
    MatToInput(img_pp, inVal);

    // pointer for network output
    ValuePtr outVal;
    std::unordered_map<Variable, ValuePtr> inputs = { {inVar, inVal} };
    std::unordered_map<Variable, ValuePtr> outputs = { { outVar, outVal } };

    // compute the output for the given input
    model->Forward(inputs, outputs,DeviceDescriptor::CPUDevice());

    // create an image from network's output
    cv::Mat raw_mask = OutputToMat(outputs[outVar]);

    // resize back to the original size
    cv::Mat mask = Resize(raw_mask, img.size());

    return mask;
}

The call to the Forward method takes 70 seconds in Debug mode and 0.5 seconds in Release mode and their result is different.

Release result:

Release_mask

Debug result:

debug_mask

This makes debugging very hard for me. i cannot trace the code in the release mode. Do you know why CNTK behaves very different in Debug? Is there any way to fix it? Thanks.

ebarsoumMS commented 6 years ago

Can you use Release_NoOpt?

springkim commented 6 years ago

Hi. Can you share your code? I want to know "Preprocess" and "MatToInput". Thanks.

cha-zhang commented 6 years ago

@darkoob12 has the issue been resolved?

ebarsoumMS commented 6 years ago

Please reactivate if the issue still there.