![]() ![]() here I share the little script I use to copy the necessary headers. But I am able to load a stored graph, restore the weights and run inference, which is IMO the most wanted functionality in C++.Īnswers above are good enough to show how to build the library, but how to collect the headers are still tricky. protobuf, so you may run in odd link-time or run-time issues. The library seems to be statically linked against e.g. Once again: this way is officially unsupported and you may run in various issues. in /usr/local/lib/python2.7/dist-packages/tensorflow/include/. The C++ header files are located around this library, e.g. just add target_link_libraries(target _pywrap_tensorflow python2.7). Then create a C++ project as you are used to (CMake, Make, Bazel, whatever you like).Īnd then you're ready to just link against this library to have TF available for your projects (and you also have to link against python2.7 libraries)! In CMake, you e.g. ![]() The prefix lib is important! You can also give it another lib*.so name - if you call it libtensorflow.so, you may get better compatibility with other programs written to work with TF. Then create a symlink to this library called lib_pywrap_tensorflow.so somewhere where your build system finds it (e.g. ![]() In my case (Ubuntu) it's located at /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow.so. Then find its library _pywrap_tensorflow.so (TF 0.* - 1.0) or _pywrap_tensorflow_internal.so (TF 1.1+). Install TF through pip ( pip install tensorflow or pip install tensorflow-gpu). It's officially unsupported, but works well if you just want to quickly jump in. I use a hack/workaround to avoid having to build the whole TF library myself (which saves both time (it's set up in 3 minutes), disk space, installing dev dependencies, and size of the resulting binary). Side Note: Paths relative to tensorflow version 1.5 (You may need to check if in your version anything changed).Īlso this link helped me a lot into finding all this infos: link Tensorflow/bazel-bin/tensorflow/libtensorflow_cc.soĪnd when you are building your project you should also specify to your compiler that you are going to use c++11 standards. Tensorflow/bazel-tensorflow/external/protobuf_archive/srcĪnd link the library to your project: tensorflow/bazel-bin/tensorflow/libtensorflow_framework.so (unused if you build with -config=monolithic) Tensorflow/bazel-tensorflow/external/eigen_archive To do that you can include this paths: tensorflow Note2: If you are thinking into using OpenCV on your project as well, there is an issue when using both libs together ( tensorflow issue) and you should use -config=monolithic.Īfter building the library you need to add it to your project. Note1: If you want to add intrinsics support you can add this flags as: -copt=-msse4.2 -copt=-mavx If you are thinking into using Tensorflow c++ api on a standalone package you probably will need tensorflow_cc.so ( There is also a c api version tensorflow.so ) to build the c++ version you can use: bazel build -c opt //tensorflow:libtensorflow_cc.so ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |