[Package]: `libtensorflow`. TensorFlow can use the TPUs on smartphones (such as Google Tensor, which has 5.2 teraFLOPS at 6 watts)
Why is it worth to add this package?
-
TensorFlow's source code is released under one of the most permissive licenses (Apache 2) and is the most popular lib for artificial neural tissue ("compute").
-
Cisco-Talos asked for a pull request which includes compute code (code which is available though dual licenses; Apache 2 or GPLv2), but says it is not acceptable to use Python backends to implement compute.
- The replacement backend for compute uses the C++ version of TensorFlow, which is difficult to produce code for without those
#includes (plus static lib or.so).
- The replacement backend for compute uses the C++ version of TensorFlow, which is difficult to produce code for without those
Home page URL
https://www.tensorflow.org/install/lang_c
Source code URL
https://github.com/tensorflow/tensorflow
Packaging policy acknowledgement
-
[x] The project is actively developed.
-
[x] The project has existing packages and is "well known".
-
[x] Licensed under an open source license.
-
[x] Not available through a language package manager: pip, npm, cpan, cargo, etc.
-
[x] Not taking up too much disk space (< 100MiB per architecture, exceptions can be made)
-
[x] Not duplicating the functionality of existing packages.
-
[x] Not serving hacking, malware, phishing, spamming, spying, ddos functionality.
-
[x] I certify that I have read Termux Packaging Policy and understand that my request will be denied if it is found lacking.
Additional information
Build steps: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/lib_package/README.md
- Use
--depth 1to just clone TensorFlow's working directory, since the repo is huge:
~ $ git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git --depth 1
Cloning into 'tensorflow'...
remote: Enumerating objects: 34943, done.
remote: Counting objects: 100% (34943/34943), done.
remote: Compressing objects: 100% (23717/23717), done.
remote: Total 34943 (delta 11587), reused 29863 (delta 10638), pack-reused 0 (from 0)
Receiving objects: 100% (34943/34943), 88.71 MiB | 3.49 MiB/s, done.
Resolving deltas: 100% (11587/11587), done.
Updating files: 100% (34418/34418), done.
~ $ ls tensorflow/
AUTHORS ISSUES.md arm_compiler.BUILD requirements_lock_3_10.txt third_party
BUILD LICENSE ci requirements_lock_3_11.txt tools
CITATION.cff README.md configure requirements_lock_3_12.txt
CODEOWNERS RELEASE.md configure.cmd requirements_lock_3_13.txt
CODE_OF_CONDUCT.md SECURITY.md configure.py requirements_lock_3_9.txt
CONTRIBUTING.md WORKSPACE models.BUILD tensorflow
https://stackoverflow.com/questions/33620794/how-to-build-and-use-google-tensorflow-c-api/43920376#43920376 has:
./configure bazel build //tensorflow:libtensorflow_cc.soThen Copy the following include headers and dynamic shared library to
/usr/local/liband/usr/local/include:mkdir /usr/local/include/tf cp -r bazel-genfiles/ /usr/local/include/tf/ cp -r tensorflow /usr/local/include/tf/ cp -r third_party /usr/local/include/tf/ cp -r bazel-bin/libtensorflow_cc.so /usr/local/lib/
This was search for the C / C++ libs for TensorFlow:
~ $ pkg install *tensorflow*
Error: Unable to locate package *tensorflow*
Error: Couldn't find any package by glob '*tensorflow*'
~ $ pkg install *tensorFlow*
Error: Unable to locate package *tensorFlow*
Error: Couldn't find any package by glob '*tensorFlow*'
~ $ pkg install *TensorFlow*
Error: Unable to locate package *TensorFlow*
Error: Couldn't find any package by glob '*TensorFlow*'
. Should post new issue for the Python libs (which have different build steps and do not use apt or pkg, but pip install tensorflow)?
If bazel is a problem, https://github.com/FloopCZ/tensorflow_cc#tensorflow_cc has cmake build steps for libtensorflow.
Termux can almost build static libs with just the #include headers from TensorFlow, but requires workarounds: https://github.com/tensorflow/tensorflow/issues/93130
Now know that TensorFlow's TPU backend has use on lots more phones. What follows is just the list of Google phones with TPU's.
- The Google Pixel 2's Pixel Visual Core... is an edgeTPU (mobile chip which can host TensorFlow)).
- The Google Pixel 4's Pixel Neural Core... is also an edgeTPU (can also host TensorFlow).
- The Google Pixel 6's Google Tensor TPU is an edgeTPU which Claude-3-Haiku says can process 5.2 teraFLOPS with average 6-watt power use, if you assume average load is 62%
Even-numbered releases share the previous odd-numbered release's edgeTPU. Of course, smartphones without TPU's can have some use for TensorFlow, too, since TensorFlow's backend support include CPU's and GPU's, but you can port such programs (whereas to use the smartphone's TPU requires TensorFlow, since most smartphones edgeTPU's protocols are not known.)