openvino: Valgrind error using int8 model
Hi!
I’ve encountered Valgrind error running the following sample on OpenVINO 2020.4.
#include <stdio.h>
#include <inference_engine.hpp>
using namespace InferenceEngine;
void testOV()
{
// Create an IR reader
CNNNetReader network_reader;
// Hardocode name of the models to be tested
const std::string Model_xml = "2020_4/face-detection-0102.xml";
const std::string Model_bin = "2020_4/face-detection-0102.bin";
// Read the model description and weights
network_reader.ReadNetwork(Model_xml);
network_reader.ReadWeights(Model_bin);
// Fetch network and setup CPU plugin
auto network = network_reader.getNetwork();
InferenceEngine::InferencePlugin plugin(InferenceEngine::PluginDispatcher({ "" }).getPluginByDevice("CPU"));
InferenceEngine::ExecutableNetwork executable_network(
plugin.LoadNetwork(network,
{
{
PluginConfigParams::KEY_CPU_THREADS_NUM, std::to_string(1)
}
}
)
);
// Setup inference request
InferenceEngine::InferRequest infer_request = executable_network.CreateInferRequest();
// Print out first and last layer just for fun
std::string inputLayerName = network.getInputsInfo().begin()->first;
std::string outputLayerName = network.getOutputsInfo().begin()->first;
printf("inputLayerName : %s outputLayerName: %s\n", inputLayerName.c_str(), outputLayerName.c_str());
// Create input_data buffer to be filled with zeros
Blob::Ptr input = infer_request.GetBlob(inputLayerName);
auto input_data = input->buffer().as<PrecisionTrait<Precision::FP32>::value_type *>();
// Fill with zeros
// It's important to put correct number here width*height*nChannels for input layer
memset(input_data, 0, 96 * 96 * 1 * sizeof(float));
// Request inference
// Note: For OpenVINO 2019 R3.1 cpu_affinity valgrind error will be raised - it's safe to ignore
infer_request.Infer();
// Fetch output buffer to read the inference results
auto output_blob = infer_request.GetBlob(outputLayerName);
auto output_data = output_blob->cbuffer().as<PrecisionTrait<Precision::FP32>::value_type*>();
// Reading the ouput data triggers valgrind error because output data is
// uninitialized for quantized models (for some reason)
// Should quantized model be used this will NOT cause a valgrind error!
if (output_data[0] > 1.0f)
{
printf("Just a test\n");
}
}
//Entry point
int main()
{
testOV();
}
Compiled with:
g++ -g -pthread -std=c++11 -I/home/osboxes/intel/openvino_2020.4.287/inference_engine/include -L/home/osboxes/intel/openvino_2020.4.287/inference_engine/lib/intel64 -L//home/osboxes/intel/openvino_2020.4.287/inference_engine/external/tbb/lib test.cpp -linference_engine -ltbb -ldl -linference_engine_legacy -o vino_test_2020_4
The error is:
==12147== Uninitialised value was created by a heap allocation
==12147== at 0x4C3089F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12147== by 0x52B0A1B: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libinference_engine_legacy.so)
==12147== by 0x51B8B28: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libinference_engine_legacy.so)
==12147== by 0xBC475A6: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.so)
==12147== by 0xBC48227: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.so)
==12147== by 0xBBFC6EB: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.so)
==12147== by 0xBBFBB2F: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.so)
==12147== by 0xBC692B4: ??? (in /home/osboxes/intel/openvino_2020.4.287/deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.so)
==12147== by 0x10F856: InferenceEngine::ExecutableNetwork::CreateInferRequest() (ie_executable_network.hpp:109)
==12147== by 0x10BD0B: testOV() (test.cpp:34)
==12147== by 0x10C264: main (test.cpp:69)
Model used for this is available at: https://download.01.org/opencv/2020/openvinotoolkit/2020.4/open_model_zoo/models_bin/3/face-detection-0102/FP16-INT8/
How can this error be solved?
Thanks in advance for the help.
Warm regards, Nikola
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (10 by maintainers)
Memory leak reproduced with AddresSanitizer:
-DENABLE_SANITIZER=ONLD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.4:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:lib/libMKLDNNPlugin.so ./benchmark_app -m face-detection-0102.xml -nireq 1 -niter 1Memory allocated by post_ops_t::append_quantization is never freed
Suspected code: https://github.com/openvinotoolkit/oneDNN/blob/b73474c80c21ae170b112803a1fc315e1549bdab/src/common/primitive_attr.hpp#L231