I am trying to integrate Tensorflow library with C++ interface into my C++ application. The problem is that straightforward build with
bazel build (some options) //tensorflow:libtensorflow.so
Makes a libtensorflow.so file that is 168Mb. That's way too much for my app. I've found some guides on reducing library size for Android, but can't find any for general desktop builds targets.
I assume that libtensorflow.so has all the whistles of TF, but what I really need is an inference engine with basic Conv ops, etc.
Any suggestions?
Thanks!
You might want to experiment with the CMake build. It has two interesting build options for your case:
setting tensorflow_BUILD_CONTRIB_KERNELS=OFF does not build kernels from tf.contrib.
setting tensorflow_BUILD_ALL_KERNELS=OFF builds only a small parts of the most common kernels.
Related
I am wondering if there is a definitive recipe for using cmake to build tensorflow and tensor for apps. I followed the instructions at https://github.com/cjweeks/tensorflow-cmake without much success and ended up having to build Eigen and Protobuf by hand and then copy relevant headers files into the the header file tree created by the Bazel build of Tensorflow.
I just built TF with CMake, VS2017, and CUDA 9.2, but had to make two manual changes:
Patch Half.h in Eigen
Change CUDA version from "9.0" to "9.2" in the main CMakeLists.txt.
Build has to be single threaded, otherwise VS runs out of heap (on my 16GB laptop). It takes a while and one project fails, but builds enough libraries to run all the examples I wanted.
Another problem with CMake build, vs. Bazel, is that the former rebuilds a bunch of projects (involving protobuf generated files) even when nothing there changes. Bazel is smarter and only compiles the changed code, then statically links all object files into a single executable, which is still faster than CMake build.
I noticed on the rules_closure repository (used by tensorflow when building it with //tensorflow/tools/pip_package:build_pip_package) that there are rules to build some dependencies like nodejs and protoc through the filegroup_external interface.
Why is the reason for not building it from scratch like other dependencies?
I ask because this approach compromises portability, as it needs to list the binaries for each platform that tries to build tensorflow (and it is even worse when there is no binary-ready for your platform).
This build configuration works deterministically, out of the box, with no systems dependencies, on recent Linux/Mac/Windows systems with Intel CPUs, and incurs no additional build latency. Our goal has been to optimize for the best build experience, for what's in our support matrix. I agree with you that an escape hatch should exist for other systems. Feel free to open an issue with the rules_closure project and CC: #jart so we can discuss more how to solve that.
Tensorflow 1.0 has introduced XLA support that includes JIT compilation and AOT compilation. For JIT compilation, I found a python test script with which it can be unit-tested. However, I've not found any python test for AOT compilation. There are bazel tests though, which can be run on source tree.
Tensorflow's link https://www.tensorflow.org/performance/xla/tfcompile provides information on how to test. But tfcompile does not make into the tensorflow's distribution content. I may be wrong here. But I could not see tfcompile anywhere in the TF's distribution directory where it is installed.
Could anyone please help me understand how to test AOT compilation on the existing distribution content OR I need to tweak something in the code to allow AOT stuff to go into distribution?
Thanks in advance.
I know you're asking specifically about AOT, but I recommend you first read this page: https://www.tensorflow.org/performance/xla/
And then read this one: https://www.tensorflow.org/performance/xla/jit
In particular note that XLA is not included in our binary distributions; you must build from source at the moment. Note that you must pick "enable XLA" when you run ./configure in order for XLA support to be enabled.
Once you've done that, Yaroslav Bulatov's advice is correct; you can build the binaries yourself, or run the tests via bazel.
I have wrote a small application in C on VxWorks 6.9 evaluation. It uses sample code and makefile from windriver/target/usr/apps/samples. I would like to compile it for other platforms beside Intel.
I have downloaded DIAB compiler evaluation which comes with an impressive list of targets, however I have issues compiling my app, especially because it's missing make rules from target/usr/make etc.
What are my options to compile a RTP/VXE without VxWorks?
Or should I install DIAB evaluation on top of VxWorks Evaluation?
Thanks!
Mono has a LLVM compiler. Is there anyway to use it with Emscripten (compile C# code to JavaScript)?
There is currently no out of the box way to do this. It might be possible, but it would require a lot of work. You would need to run mono in full AOT (ahead of time) compilation mode with the LLVM codegen. But there are many issues:
LLVM is currently not used for all methods, and mono falls back to it's own code generator in a number of cases. You would either need to get the LLVM suport working for all cases, or provide the JS code needed when LLVM cannot be used.
Mono currently has a number of architecture specific files (x86, amd64, arm, etc) and would probably need equivalent for JS, both for the code generation and for the AOT runtime.
And so on...
you can try to use C# Native
have a look here http://csnative.codeplex.com
Even if you run mono in full AOT and compile your program with LLVM it is not possible to use it with emscripten. This is quote from my discussion in mono group:
Besides that, no, it's not possible to use emscripten with mono's llvm output for a lot of reasons.
The output embeds calls to the mono runtime and some trampilines.
Mono use a custom LLVM with custom IR operations and that won't work on emscripten without some work on their end.