All Projects → snipsco → Tensorflow Build

snipsco / Tensorflow Build

Licence: mit
A set of scripts to (cross-)build the Tensorflow C lib for various architectures / OS

Programming Languages

shell
77523 projects
rust
11053 projects

Projects that are alternatives of or similar to Tensorflow Build

Glsl Optimizer
GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.
Stars: ✭ 1,506 (+750.85%)
Mutual labels:  cross-compiler
Proton Clang
Proton Clang toolchains builds in the form of a continuously updating Git repository. Clone with --depth=1.
Stars: ✭ 126 (-28.81%)
Mutual labels:  cross-compiler
Dotfiles And Scripts
🎣 Dotfiles and scripts providing cumbersome configure details and other senseless stuff. 一些无聊的脚本和配置文件
Stars: ✭ 144 (-18.64%)
Mutual labels:  arch
Docker Ce Packaging
Packaging scripts for Docker CE
Stars: ✭ 111 (-37.29%)
Mutual labels:  deb
Mingw W64 Build
MinGW-w64 build script
Stars: ✭ 124 (-29.94%)
Mutual labels:  cross-compiler
Aliddns
aliyun ddns for golang【阿里云DDNS服务,用来将自己的动态IP同步到自己的域名解析服务器,安装方便,配置简单,默认支持Linux和MacOS以后台服务方式持续运行】
Stars: ✭ 136 (-23.16%)
Mutual labels:  deb
My dotfiles
Just a collections of my dotfiles...
Stars: ✭ 101 (-42.94%)
Mutual labels:  arch
Termux Create Package
Python script to create Termux packages easily.
Stars: ✭ 155 (-12.43%)
Mutual labels:  deb
Electron Builder
A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
Stars: ✭ 11,653 (+6483.62%)
Mutual labels:  deb
Dotfiles
Collection of i3-gaps Dotfiles
Stars: ✭ 143 (-19.21%)
Mutual labels:  arch
Redishappy
Redis Sentinel high availabillity daemon
Stars: ✭ 111 (-37.29%)
Mutual labels:  deb
Cylon
A CLI TUI menu driven bash shell script supporting updates, maintenance, backups and system checks for an Arch based Linux distro
Stars: ✭ 121 (-31.64%)
Mutual labels:  arch
Notepanda
📃 A simple cross-platform notepad. Based on Qt and C++.
Stars: ✭ 134 (-24.29%)
Mutual labels:  arch
Dotfiles
My bspwm dotfiles. Grab whatever you need! :)
Stars: ✭ 111 (-37.29%)
Mutual labels:  arch
Pacback
Advanced Version Control for Arch Linux
Stars: ✭ 146 (-17.51%)
Mutual labels:  arch
Sbt Native Packager
sbt Native Packager
Stars: ✭ 1,480 (+736.16%)
Mutual labels:  deb
App Outlet
A Universal linux app store
Stars: ✭ 131 (-25.99%)
Mutual labels:  deb
Photoshopcclinux
Photoshop CC v19 installer for Gnu/Linux
Stars: ✭ 2,894 (+1535.03%)
Mutual labels:  arch
Tmoe Linux
🍭Without any basic knowledge of linux shell,you can easily install and configure a GNU/Linux graphical desktop environment on 📱Android termux and 💻WSL .🍰You can also run VSCode on your android phone.🍹Graphical qemu manager,🐋support running docker on Android.配置WSL和安卓手机的linux容器,桌面环境,主题美化,远程桌面,音频服务,镜像源,uefi开机启动项,webdav(nginx),fcitx输入法以及qemu-system虚拟机...
Stars: ✭ 149 (-15.82%)
Mutual labels:  arch
Archinstall
Arch Linux installer - guided, templates etc.
Stars: ✭ 140 (-20.9%)
Mutual labels:  arch

‼️ ‼️ Not maintained ‼️ ‼️

We do not use tensorflow-build anymore at snips, we make our models run on small devices using tract. The scripts here work to compile tf 1.3.1 and have not be tested on later versions

tensorflow-build

A set of scripts to (cross-)build the Tensorflow C lib for various architectures / OS

The goal of this repo is to provide packages containing the libtensorflow_c.so file as well as a corresponding pc file so that is .so can be used with pkg-config (one use of this is linking tensorflow with rust programs, see the bonus at the end)

We're using these scripts on Ubuntu and Archlinux, the commands given below assume that you're on a fairly recent Ubuntu box.

Theses script are a WIP but a good starting point on how to cross compile tensorflow. Expect to have to edit and tweak them to fit your needs.

Supported OS / Arch:

OS Available archs
Debian Like armhf [deb] (raspbian, crosscompiled, tested on Raspberry Pi 0, 2 & 3)
amd64 [deb]
Android armeabi-v7a [sysroot overlay]
arm64-v8a [sysroot overlay]
x86 [sysroot overlay]
x86_64 [sysroot overlay]
iOS [sysroot overlay]
Archlinux i686 / x86_64 use this aur [PKGBUILD]
macOS x86_64 brew install libtensorflow

Installing the dependencies

Installing bazel

Before runing these scripts, you need to have bazel

$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install bazel

Other build dependencies

You'll also need numpy

$ sudo apt-get install python3-numpy

Using the scripts

Here is a small description of interesting scripts in this repo

Script Description
compile.sh Clones and build tensorflow for current machine. Takes the tensorflow version as a parameter
cross-compile.sh Generic script for cloning and building tensorflow using a cross toolchain. Launch it without args for usage
compile-arm.sh Clones the raspberry/tools repository an launches a cross compilation using the toolchain in it. Takes the tensorflow version as a parameter
compile-android.sh Download Android NDK and launch a crosscompilation for android using it. Takes the tensorflow version, android arch and package version as parameters
compile-ios.sh Clone and build tensorflow for iOS with the C API.
create-pkgconfig.sh Generic script for creating a pc. Launch it without args for usage

Building a deb

$ cd debian
$ ./create-deb-native.sh # or ./create-deb-armhf.sh then go grab a cup of coffee
$ sudo dpkg -i target/libtensorflow_1.0.0-snips-5_amd64.deb

Bonus : Using with Rust

You can use tensorflow with your rust projects using the tensorflow crate, its dependency tensorflow-sys will seek the libtensorflow_c.so using pkgconfig and build it if it doesn't find it, which can take some time...

Native build

Install the package then cargo build should find the lib \o/

Cross compile build

For cross compilation, you need a few more steps, the examples below are for a building for a Raspberry Pi 2/3 from a linux box

First, you need the rust target for the Pi

$ rustup target install armv7-unknown-linux-gnueabihf

Then you need a toolchain for the pi, let's use the one provided by RaspberryPi

$ git clone https://github.com/raspberrypi/tools

Configure cargo to use the toochain by adding this snippet to you ~/.cargo/config

[target.armv7-unknown-linux-gnueabihf]
linker = "/path/to/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc"

We now need the .so file of tensorflow for the target arch, let's build the 1.0.0

$ ./compile-arm.sh v1.0.0

The .so is located in target/tensorflow/bazel-bin/tensorflow/libtensorflow.so you may want to move it somewhere else

Let's then generate the .pc file

$ ./create-pkgconfig.sh tensorflow_c /folder/where/the/so/is 1.0.0 "Tensorflow C Library" > /path/to/pc/file

Now that all is done, we can use cargo to crossbuild the app

$ PKG_CONFIG_LIBDIR=/folder/where/the/pcfile/is PKG_CONFIG_ALLOW_CROSS=1 cargo build

Enjoy!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].