-
Notifications
You must be signed in to change notification settings - Fork 428
Add support for static linking #351
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
Conversation
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.
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. |
I've signed the CLA |
Can you make sure the checks all pass? |
Whoops, looks like I forgot to run |
The checks should pass now but I'm unable to rerun them |
There was a problem hiding this 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` |
There was a problem hiding this comment.
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.)
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 |
I'm sorry to hear that, and I'm sorry I didn't review this earlier. I hope your job situation is okay! |
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 commitonly allows the user to ask the build script to use the static library
they have built.