Code Monkey home page Code Monkey logo

Comments (2)

Venkat6871 avatar Venkat6871 commented on June 10, 2024

Hi @allogic ,

  • Sorry for the delay, Here i am seeing compatibility mismatch. Could you go through this documentation once? Please let us know if issue still persists.

Thank you!

from tensorflow.

allogic avatar allogic commented on June 10, 2024

Look, I was going through the documentation for a whole week and still could not use tensorflow as a simple static library.
Here is a simple step by step guide to reproduce the behavior I'm experiencing.

NOTE: session_header.lib is not being built by default. It is only registered in bazel tests, but is not linked into the final binary!

git clone --depth 1 --branch v2.16.1 https://github.com/tensorflow/tensorflow
# ensure "session_header.lib" is being built in //tensorflow/cc/BUILD
python configure.py

set BAZEL_SH="C:\msys64\usr\bin\bash.exe" # Is required for some odd reason...

bazel clean --expunge

It seems clang is the preferred compiler starting with tensorflow 2.16.1. But when building with clang using the following command, clang produces a linker error which I have never encountered. It seems to be a problem on the LLVM site.

NOTE: I've not tested newer versions of clang, only the one described in the documentation!

bazel build --config=win_clang //tensorflow:tensorflow.lib
# time_rep_timespec.obj error LNK2019: unresolved external symbol _Thrd_sleep_for referenced in function "void __cdecl std::this_thread::sleep_for<__int64,struct std::ratio<1,1000000000> >(class std::chrono::duration<__int64,struct std::ratio<1,1000000000> > const &)" (??$sleep_for@_JU?$ratio@$00$0DLJKMKAA@@std@@@this_thread@std@@YAXAEBV?$duration@_JU?$ratio@$00$0DLJKMKAA@@std@@@chrono@1@@Z)

Regardless, when I build with MSVC on the other hand, it works as expected. It generates all the static libraries that I can link against without error.

The monolithic option is described in the .bazelrc file and is used to create a mostly static build. It also states that it will DISABLE modular op registration which is the problem I am facing currently. All tho it "states" it will be disabled, it does not.
Modular op registration is still enabled and my guess is that all the operators get optimized away during the build to safe binary size.

bazel build --config=monolithic //tensorflow:tensorflow.lib

Last but not least I'm generating the headers.

bazel build //tensorflow:install_headers

Here are all the software versions that I use. They are strictly limited to the versions described in the documentation!

# Tensorflow: 2.16.1
# Python: 3.13.0a6
# LLVM: 17.0.6
# MSVC: 19.39.33520
# Bazel: 6.5.0

I'm forced to leave it like this as I have no proper experience with Bazel and Tensorflow as a whole. But I would be happy if someone could explain to me what I'm missing or doing wrong. It can't be that big of a problem, since the modular op registration has to be disabled somewhere...

from tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.