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

Feature request: provide a means to configure, build, and install that includes cc #15290

Closed
unitive-jim opened this issue Dec 12, 2017 · 20 comments
Labels
stale This label marks the issue/pr stale - to be closed automatically if no activity stat:contribution welcome Status - Contributions welcome

Comments

@unitive-jim
Copy link

Please go to Stack Overflow for help and support:

https://stackoverflow.com/questions/tagged/tensorflow

If you open a GitHub issue, here is our policy:

  1. It must be a bug or a feature request.
  2. The form below must be filled out.
  3. It shouldn't be a TensorBoard issue. Those go here.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.


System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): N/A
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Both Mac and Linux
  • TensorFlow installed from (source or binary): Source
  • TensorFlow version (use command below): 1.4
  • Python version: 3.6.3, but not relevant
  • Bazel version (if compiling from source): 0.8.1, but not relevant
  • GCC/Compiler version (if compiling from source): Both GCC and clang, but not relevant
  • CUDA/cuDNN version: N/A
  • GPU model and memory: N/A
  • Exact command to reproduce: N/A

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.

Tensorflow doesn't seem to have a clean way to install from sources to support both python and C++ development. When we install from sources, only the core tensorflow framework is installed in the python site-packages directory. The cc headers (and maybe others) are not included. Likewise the libtensorflow_cc.so is not built. It's surprising that there is so little documentation for how C++ developers are expected to develop tensorflow applications. My use case is probably common: I want to train and test my model using python, but I want to deploy an application that does prediction/inference with the app written in C++.

I have managed once to successfully install the headers and libraries I need into /usr/local/... on a Mac, but in doing so I lost some of the CPU optimizations that I had specified when doing the standard build from sources. Now I need to repeat this process on Linux, where I need GPU support, and want to make sure I get it right.

It would be so nice if there was something close to the standard ./configure; make; make install that could install headers and libraries into a chosen directory.

Source code / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

@gunan
Copy link
Contributor

gunan commented Dec 14, 2017

Have you followed this page:
https://www.tensorflow.org/install/install_sources

I agree that ultimate installation instructions are for python pip packages. That may be confusing. But once you have the source directory, you should be able to build anything.

@asimshankar do we have a document to describe libtensorflow_cc.so build and installation?

@unitive-jim
Copy link
Author

Yes, I have gone through all of the steps to build and install the python components into site-packages from source. I've also used bazel to build libtensorflow_cc.so. But there are still several other manual steps required to arrange for all of the necessary C++ headers to be installed in such a way that C++ applications can compile independently of the tensorflow repository.

In my search for the best way to do this, the best resource I have found is on stackoverflow:
https://stackoverflow.com/questions/33620794/how-to-build-and-use-google-tensorflow-c-api

That question is two years old(!!) and none of the answers are (IMHO) satisfactory. The answer that comes closest is this one. But the steps as shown there did not work for me, possibly due to changes to tensorflow between the time the answer was written and the current r1.4 release. I have been able modify the steps to make something that does work, but it is really unacceptable for the Tensorflow team to expect every developer to discover on their own how to do this. There really should be something like the standard unix recipe: .configure; make cc-installer; sudo install-cc.sh;. With bazel, the steps might look like this:

  1. ./configure # a new question is added: "Do you want to build for C++ development?"
  2. bazel build --config=opt --config=cuda //tensorflow/tools/cc_package:build_cc_package
  3. sudo install-cc-package.sh

The result from the above steps would be the installation of a directory at the default path /usr/local/include/tf, but the actual path should be an option provided during the ./configure step. The tf directory should contain all of the headers necessary for C++ development. It would a superset of all of the headers currently installed into ../site-packages/tensforflow/include, but following the same directory organization. The installer script would also install libtensorflow_cc.so and libtensorflow_framework.so into /usr/local/lib or some other location chosen during the ./configure step.

Let me be clear: I personally am not blocked, as I now have a working configuration on both my Mac and Linux development machines. But other developers (and me sometime in the future) will need to do this, and it seems bizarre that the Tensorflow team does not have a documented and easy to follow process that all developers who need C++ development can follow, and will continue to work with each new tensorflow release. I could document what I do, possibly on the above stackoverflow thread, but the Tensorflow community is not served well by that hack.

@tensorflowbutler
Copy link
Member

It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly.

@tensorflowbutler
Copy link
Member

Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

1 similar comment
@tensorflowbutler
Copy link
Member

Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

@jimlloyd
Copy link

I'm curious if there has been any progress on this issue. I'm currently working on making a Docker image to deploy to Google Cloud and I've discovered that I am once again blocked by this issue.

If I pull one of the docker images, I find that libtensorflow_cc.so is not included anywhere in the image. What is worse, when I try to build it (with gpu support) I get errors, similar to this issue: #2143

I tried both nightly-devel-gpu-py3 and 1.5.0-devel-gpu-py3 and obtained the same error.

This error seems to indicate that libtensorflow_cc.so is not even built in your continuous integration. Is that correct?

@gunan
Copy link
Contributor

gunan commented Feb 14, 2018

@asimshankar @allenl to comment.
I think many symbols exporrted by libtensorflow_cc.so are also exported by the .so files distributed by our pip packages. We should wait for confirmation though.
You are correct that in our dockerfiles we do not have anything other than the py libraries. Maybe we should also make C and Java libraries available in these.

@jimlloyd
Copy link

The pip package only includes libtensorflow_framework.so, which is not sufficient for C++ development.

@gunan
Copy link
Contributor

gunan commented Feb 16, 2018

pywrap_tensorflow.so is also in the pip package, it may be in a harder to locate place, and may need to be moved around in our pip package. And as far as I know, that .so file should be exporting every single C++ object in TF (which is something we are working to fix).

@tensorflowbutler
Copy link
Member

Nagging Assignee @gunan: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

1 similar comment
@tensorflowbutler
Copy link
Member

Nagging Assignee @gunan: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

@jwatte
Copy link

jwatte commented Mar 20, 2018

"you should be able to build anything"

I agree, I should be.
But how do I do it?
How do I even know what it is I want to build?
How do I know that libtensorflow_cc.so is a target I should ask Bazel to build?
What other targets should I build?
Which headers should go into a public include directory, as opposed to are for internal use only?

I can't find any documentation at all on how to build and user TensorFlow as a C and C++ library, or much about what all can be built with the Bazel builder at all. I'm sure some of that is me not being good with Bazel, but that can't be the only thing getting in the way here.

Note that https://www.tensorflow.org/install/install_sources explicitly talks about how to build the pip packages, not how to build for C++.

@gunan
Copy link
Contributor

gunan commented Mar 20, 2018

@asimshankar Do we have documentation for libtensorflow?

@tensorflowbutler
Copy link
Member

Nagging Assignee @gunan: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

@jimlloyd
Copy link

Can @asimshankar please reply to this thread?

@asimshankar
Copy link
Contributor

The C library package (consisting essentially of a single header file and a few shared libraries) can be built using the process we use for building release binaries. (See README and StackOverflow answer).

For the C++ library, we haven't had the bandwidth to support that ourselves yet and have relied on community support for that (see #2412 (comment) and #2412 (comment) and #2412 (comment) - credit to @FloopCZ and others).

If someone would like to contribute a packaging rule for the C++ library by adding a BUILD target similar to libtensorflow in https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/lib_package/BUILD, that would be awesome.

@tensorflowbutler
Copy link
Member

Please remove the assignee, as this issue is inviting external contributions. Otherwise, remove the contributions welcome label. Thank you.

@ansar-sa
Copy link

Propose that this project should be part of the official tensorflow docker images: https://github.com/FloopCZ/tensorflow_cc

Building and using libtensorflow_cc.so from source is non-trivial and burns dev time. Would be good for community if the official images support easy c++ dev and integration. Thanks.

@github-actions
Copy link

This issue is stale because it has been open for 180 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label Mar 28, 2023
Copy link

This issue was closed because it has been inactive for 1 year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This label marks the issue/pr stale - to be closed automatically if no activity stat:contribution welcome Status - Contributions welcome
Projects
None yet
Development

No branches or pull requests

7 participants