Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow::RunOptions::RunOptions(void) symbol missing in built tensorflow.dll (Windows) #66490

Open
advnpzn opened this issue Apr 26, 2024 · 3 comments
Assignees
Labels
stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.16 type:build/install Build and install issues

Comments

@advnpzn
Copy link

advnpzn commented Apr 26, 2024

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

tf 2.16.1

Custom code

No

OS platform and distribution

Windows 11 23H2 Build 22631.3296

Mobile device

N/A

Python version

3.11.2

Bazel version

6.5.0

GCC/compiler version

LLVM/clang 17.0.6 & MSVC 19.29.30154

CUDA/cuDNN version

N/A

GPU model and memory

N/A

Current behavior?

I was trying to build the tensorflow.dll in Windows to use the C++ API in my code. After successfully building tensorflow.dll and trying to use it in the code, I had faced several missing symbols error while linking. But by adding TF_EXPORT I was able to remove most of it. But there was still one symbol that was missing, which is tensorflow::RunOptions::RunOptions(void).

As far as I observed this is from a dynamically generated config.pb.h from tensorflow/core/protobuf/config.proto. What I have tried is to apply TF_EXPORT to the generated config.pb.h file in relevant places. But as soon as I run the bazel build command for the target, The config.pb.h and the config.pb.cc files are regenerated, thus whatever changes I made for exporting those symbols invalid. And after the build I still get the same tensorflow::RunOptions::RunOptions(void) symbol missing error while linking.

My question is how can I specifically export symbols from dynamically generated stub files from proto files while building ?
I was surprised no one has faced this problem before.

Standalone code to reproduce the issue

Build tensorflow with the following command.

`bazelisk.exe build --config=opt --config=win_clang //tensorflow:tensorflow.dll //tensorflow:tensorflow_dll_import_lib //tensorflow:install_headers`

Use the resulting `tensorflow.dll` and `tensorflow.lib` to compile custom code in MSVC.


    std::string filename = std::filesystem::path(model).filename().string();
    filename.resize(filename.length() - 3);
    tensorflow::SavedModelBundle bundle;
    tensorflow::SessionOptions session_options;
    tensorflow::RunOptions run_options;
    run_options.Clear();
    tensorflow::Status status = tensorflow::LoadSavedModel(session_options, run_options, model, { }, & bundle);

Relevant log output

unresolved external symbol "__declspec(dllimport) public: __cdecl tensorflow::RunOptions::RunOptions(void)" (__imp_??0RunOptions@tensorflow@@QEAA@XZ) referenced in function "public: bool __cdecl ModelCollection::Add_v2(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?Add_v2@ModelCollection@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAV23@@Z)
@google-ml-butler google-ml-butler bot added the type:build/install Build and install issues label Apr 26, 2024
@tilakrayal tilakrayal added TF 2.16 subtype:windows Windows Build/Installation Issues labels Apr 29, 2024
@tilakrayal
Copy link
Contributor

@advnpzn,
Could you please provide the complete error log of the installation process which helps us to debug the issue in an effective way. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label Apr 30, 2024
@advnpzn
Copy link
Author

advnpzn commented Apr 30, 2024

Hi @tilakrayal

Could you please specify which logs do you want specifically?
I could provide you the bazel build log for tensorflow.dll and the error output I get while compiling/linking a sample program with that tensorflow.dll.

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label Apr 30, 2024
@tilakrayal
Copy link
Contributor

@advnpzn,
The logs which are available while trying to build the tensorflow on WIndows would be helpful for us to debug the issue and provide the resolution. Thank you!

@tilakrayal tilakrayal added the stat:awaiting response Status - Awaiting response from author label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.16 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

2 participants