Home > Enterprise >  Should Tensorflow C DLL be necessarily compiled in debug modus to be able to debug/run code depend
Should Tensorflow C DLL be necessarily compiled in debug modus to be able to debug/run code depend

Time:11-19

Currently I'm writing an extension for one proprietary software. Logs unfortunately are not fully available, so this is work in progress. Extension is compiled to DLL using Microsoft Visual Studio 2019, this DLL has dependency on Tensorflow 2.6 DLL. The extension basically loads Saved Model using

LoadSavedModel(session_options, run_options, m_modelDir, { tensorflow::kSavedModelTagServe }, &model_bundle_lite);

and performs inference on images using

model_bundle_lite.GetSession()->Run(inputs_, output_names, {}, &predictions);

Tensorflow DLL was built using bazel according to instructions.

Currently functionally there seems to be no problems, if I compile my extension with Release Configuration. We wanted to check some aspects compiling our Extension with Debug Configuration and utilizing the original Tensorflow.dll. Nothing changes, models are the same, images are the same. But the extension crashes at LoadSavedModel(session_options, run_options, m_modelDir, { tensorflow::kSavedModelTagServe }, &model_bundle_lite); The errors are not catched with standard catch statements. I cannot debug the code that follows after the model loading.

What could be the reason for this behaviour? I wanted to check the functionality of our code only, I don't want to debug TF functions themselves.

CodePudding user response:

Mixing up debug and release builds can cause serious issues based on the generated code. Debug builds could use some special debug allocators or something else which you do not know.

What you can try to do to get more information about the issue is to attach something like WinDbg and load the model again. This helped me quite often to see if any structured exceptions were thrown during the loading. To do this you have to:

  • Install Windb (just google for it)
  • Open it and attach the debugger to your application
  • Try to load the model
  • Check the logs and look for any thrown exception

CodePudding user response:

In Visual Studio you can get debug information in "Release" configuration by disabling optimizations and enabling the debug-output; as long as you don't change run-time library and avoid changing preprocessor flags.

So a "Release" configuration can in fact be primarily a "Debug"-configuration.

This can be done on a per-project (and for some settings per-file) basis.

More details in: https://docs.microsoft.com/en-us/cpp/build/how-to-debug-a-release-build?view=msvc-170

And the /Z7 debug-format may have advantages in your scenario.

But do not try to mix "Debug" and "Release" project configurations, and some library debug settings cannot be disabled in this way.

  • Related