• This repository has been archived on 22/Jan/2019
  • Stars
    star
    178
  • Rank 214,989 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

โ€ผ๏ธ โ€ผ๏ธ 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!

More Repositories

1

snips-nlu

Snips Python library to extract meaning from text
Python
3,889
star
2

Postal

A Swift framework for working with emails
Swift
653
star
3

snips-nlu-rs

Snips NLU rust implementation
Rust
340
star
4

ntm-lasagne

Neural Turing Machines library in Theano with Lasagne
Python
300
star
5

awesome-snips

A curated list of awesome Snips projects
276
star
6

rust-threshold-secret-sharing

A pure-Rust implementation of various threshold secret sharing schemes
Rust
156
star
7

react-inview-monitor

Declarative in-view scroll monitor for React JS
JavaScript
114
star
8

rust-paillier

A pure-Rust implementation of the Paillier encryption scheme
Rust
80
star
9

snips-nlu-ontology

Ontology of Snips NLU
Rust
57
star
10

react-scrolling-color-background

background with color transitioning as you scroll, declarative and easy to setup
JavaScript
57
star
11

sda

Secure distributed aggregation of high-dimensional vectors
Rust
55
star
12

snips-skill-respeaker

Official Snips Animation Feedback For Makers Kits/Dev Kits, supporting all kinds of APA102 based LED hardwares.
C
41
star
13

snips-record-personal-hotword

Python
40
star
14

hermes-protocol

Definition of the Hermes protocol used by the Snips platform
Rust
36
star
15

snips-nlu-language-resources

Language resources for the Snips Natural Language Understanding (NLU)
Python
34
star
16

snips-platform-android-demo

A demo of the Snips Platform for Android
Java
22
star
17

paillier-libraries-benchmarks

Companion repository for blog post on benchmarking implementations of Paillier encryption
Go
19
star
18

SuperCombinators

[Deprecated] A Swift parser combinator framework
Swift
19
star
19

nlp-workshops

Introduction and tutorial about Natural Language Processing
Jupyter Notebook
16
star
20

snipsmanager

The Snips Assistant Manager
Python
16
star
21

snips-nlu-parsers

Rust crate for entity parsing
Rust
16
star
22

gazetteer-entity-parser

Rust library for parsing and resolving entity values based on a gazetteer
Rust
16
star
23

snips-issues

Feel free to share your bugs with us.
14
star
24

snips-app-sonos

Sonos app for Snips
Python
13
star
25

snips-nlu-metrics

Python package to compute metrics on an NLU intent parsing pipeline
Python
13
star
26

snips-nlu-utils

Rust library for NLU utils with wrappers in other languages
Rust
12
star
27

snips-app-template-py

Action code template written in Python.
Python
11
star
28

snips-platform-swift

The Swift framework for the Snips Platform
Swift
11
star
29

snips-actions-templates

Template files for snips actions
Python
11
star
30

snips-nlu-resources

10
star
31

play-mongo-bson

Scala client for MongoDB using macros for case class serialization/deserialization
Scala
10
star
32

snips-platform-docker

Shell
10
star
33

snips-skill-owm

OpenWeatherMap skill for Snips
Python
9
star
34

snips-javascript-toolkit

Everything you need in order to write Snips actions in javascript / typescript.
TypeScript
9
star
35

snips-skill-hue

Philips Hue skill for Snips
Python
8
star
36

create-snips-action

Generator for writing Snips action code in Javascript/Typescript.
JavaScript
7
star
37

crfsuite-rs

Rust bindings for CRFSuite
C
7
star
38

snips-jeedom-plugin

Jeedom plugin allows connecting Snips voice assistant with Jeedom platform.
PHP
6
star
39

snips-demo-dev-kit

Official action code for Snips Voice Interaction Development Kit. (Temperature & Relay)
Python
6
star
40

snips-javascript-actions-runner

A lightweight javascript actions runner. ๐Ÿƒโ€โ™‚๏ธ
JavaScript
5
star
41

ripb

A rust crate providing an implementation of a lock-free type-safe in-process bus.
Rust
4
star
42

snips-action-alarm

Snips action code for the Alarm app
TypeScript
4
star
43

snipsmanagercore

Core Python utilities for the Snips Manager
Python
4
star
44

snips-skill-fakeweather

Fake weather forecasts for Snips
Python
3
star
45

snips-app-relay-switch

Control the switch connected on Raspberry Pi by using your voice.
Python
3
star
46

snips-skill-weather

skill for the Snips assistant, En & Fr
JavaScript
2
star
47

snips-skill-weather-tts

Skill to show how to parse a weather intent and respond with a TTS.
Python
2
star
48

snips-skill-neopixel

NeoPixel Ring 24 skill for Snips
Python
2
star
49

snips-app-sht31

Get temperature and humidity from SHT31 (I2C protocol) by using your voice.
Python
2
star
50

snips-actions-runner-hook

Temporary solution to link snips-skill-server and snips-actions-runner
JavaScript
1
star
51

braccio_arm_demo

Code to control the braccio robotic arm for maker fare
Python
1
star
52

snips-action-reminder

Snips action code for the Reminder app
TypeScript
1
star
53

snips-action-timer

Snips action code for the Timer app
TypeScript
1
star
54

snips-action-unit-converter

Snips action code for the Unit Converter app
TypeScript
1
star
55

snips-action-nutrition

Snips action code for the Nutrition app
TypeScript
1
star
56

homebrew-snips

Snips formulae for the Homebrew package manager
Ruby
1
star
57

snipsair_whitepaper

Snips whitepapers, summaries, traductions etc.. Get in touch if you would like to help translate!
1
star
58

snips-skill-hue-pro

Handler for [Smart Light - Hue] bundle.
Python
1
star
59

SDP-swift

Swift reference implementation for Simple Datagram Protocol.
Swift
1
star
60

create-snips-action-typescript

Generator for writing Snips action code in Typescript.
TypeScript
1
star
61

Snips_Lights

Arduino library for light animations for the smart speaker project.
C++
1
star
62

snips-skill-times-tables-quiz

This skill enable your snips voice assistant to give you a quiz on times tables under the form of a dialog session.
Python
1
star