terryzhao127 / tensorflow-windows-build-script

A script to automate building Tensorflow on Windows and solve some problems
GNU General Public License v3.0
102 stars 35 forks source link

Missing symbols at runtime #12

Closed IljaAndrejevic closed 5 years ago

IljaAndrejevic commented 5 years ago

Hi, first of all, thank you very much for the hard work you done on helping the folks out ther to compile TensorFlow for Windows. Without your scripts I would be so close at having a first c++ demo app under Windows.

Now to my problem: Im trying to build an example TensorFlow 1.12 application with CUDA support on Windows 10 with Visual Studio 2017. I managed to compile a liblibtensorflow_cc.so and liblibtensorflow_cc.so.ifso with GPU support. After renaming it and collecting all needed headers I also managed it to build a first very basic test application, i found on TensorFlow website:

`// tensorflow/cc/example/example.cc

include "tensorflow/cc/client/client_session.h"

include "tensorflow/cc/ops/standard_ops.h"

include "tensorflow/core/framework/tensor.h"

int main() { using namespace tensorflow; using namespace tensorflow::ops; Scope root = Scope::NewRootScope(); // Matrix A = [3 2; -1 0] auto A = Const(root, { {3.f, 2.f}, {-1.f, 0.f} }); // Vector b = [3 5] auto b = Const(root, { {3.f, 5.f} }); // v = Ab^T auto v = MatMul(root.WithOpName("v"), A, b, MatMul::TransposeB(true)); std::vector outputs; ClientSession session(root); // Run and fetch v TF_CHECK_OK(session.Run({v}, &outputs)); // Expect outputs[0] == [19; -3] LOG(INFO) << outputs[0].matrix(); return 0; }`

This one is compiling and working fine.

Then I wonted to create a first basic program which should also do inference on images. For this reason I found this example: https://github.com/hluu11/SimpleTF-CPP After first compilation try, Visual Studio reported some missing symbols, which i added to the tf_exported_symbols_msvc.lds and build TensorFlow again. Which worked fine. Then I build the example program in Visual Studio, which also worked fine.

And now my problem: If I start this program, I got a message that a symbol entrie point cant be found at run time. (This is just the translation from German, because I'm using a German Windows. Wo I'm not sure if this is the correct english version of the message)

The missing entrie point is to this symbol: ??0Placeholder@ops@tensorflow@@QEAA@AEBVScope@2@W4DataType@2@@Z

Any idea how this could be fixed? Did I missed some definitions or any export rules?

Thank you for helping

terryzhao127 commented 5 years ago

Have you properly linked the .dll file?

IljaAndrejevic commented 5 years ago

Hi, after I returned to my working desk after a recreational weekend, I found the issue. Everything was linked properly. The problem was very simple. I just forgot to copy the .dll file to the executable. Every thing is running fine now.

Thank you very much for your help.

By the way, did you tried to build the .dll with debug symbols?

StevenRoodhorst commented 5 years ago

Vacation always helps fixing problems 😉 The DLL is built without exposing any symbols, so any debug symbol you want to have, you will have to add it yourself. You can however build it in debug mode in bazel. See here

Scorillo47 commented 5 years ago

I have the same problem. The libtensorflow_cc.dll is crashing when I attempt to load my custom op but I don't have PDB symbols for this DLL so I could debug it.

Tried to provide the option --compilation_mode=dbg in Bazel but I get a compilation error after a few minutes.

powershell -File .\build.ps1 -ReserveSource -ReserveVenv -BuildCppAPI -BazelBuildParameters "--config=opt --config=cuda --define=no_tensorflow_py_deps=true --copt=-nvcc_options=disable-warnings //tensorflow:libtensorflow_cc.so --verbose_failures --compilation_mode=dbg"