Skip to content

Conversation

sgrif
Copy link

@sgrif sgrif commented Mar 30, 2022

While tensorflow doesn't officially support building a static library,
it is relatively straightforward on Unix using instructions found by the
community at tensorflow/tensorflow#28388. This
allows tensorflow-sys to use a static library should one already exist.

No attempt is made to add any support for automatically building a
static library. It is entirely on the user to go through the trouble of
producing libtensorflow.a should they want to use it. This commit
only allows the user to ask the build script to use the static library
they have built.

While tensorflow doesn't officially support building a static library,
it is relatively straightforward on Unix using instructions found by the
community at tensorflow/tensorflow#28388. This
allows tensorflow-sys to use a static library should one already exist.

No attempt is made to add any support for automatically building a
static library. It is entirely on the user to go through the trouble of
producing `libtensorflow.a` should they want to use it. This commit
*only* allows the user to ask the build script to use the static library
they have built.
@google-cla
Copy link

google-cla bot commented Mar 30, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@sgrif
Copy link
Author

sgrif commented Mar 30, 2022

I've signed the CLA

@adamcrume
Copy link
Contributor

Can you make sure the checks all pass?

@sgrif
Copy link
Author

sgrif commented Apr 17, 2022

Whoops, looks like I forgot to run cargo fmt. I will make sure to run it first thing Monday morning. The PR should otherwise be fine to review in the meantime

@sgrif
Copy link
Author

sgrif commented Apr 19, 2022

The checks should pass now but I'm unable to rerun them

Copy link
Contributor

@adamcrume adamcrume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run ./test-all while building statically? When I tried, it crashed with: Non-OK-status: status status: NOT_FOUND: Op type not registered 'NoOp'.

@@ -60,6 +60,9 @@ compiled library will be picked up.
**macOS Note**: Via [Homebrew](https://brew.sh/), you can just run
`brew install libtensorflow`.

To statically link Tensorflow, set the environment variable
`TENSORFLOW_LIB_STATIC` to the directory containing `libtensorflow.a`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point to tensorflow/tensorflow#28388 (I assume tensorflow/tensorflow#28388 (comment) specifically) for how to build libtensorflow.a? We may want to include explicit instructions here, e.g.

bazel build --config=monolithic -j 1 //tensorflow:libtensorflow_cc.so
ar -cr libtensorflow.a $(cat bazel-bin/tensorflow/libtensorflow_cc.so.*.params | grep '\.o$')

(Which is what I did, anyway.)

@sgrif
Copy link
Author

sgrif commented Apr 22, 2022

I left the job where this was desirable and no longer have the machine I was using to work on this. So someone else will have to pick this up to make this happen.

Sorry for wasting your time

@sgrif sgrif closed this Apr 22, 2022
@adamcrume
Copy link
Contributor

I'm sorry to hear that, and I'm sorry I didn't review this earlier. I hope your job situation is okay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants