tomasreimers / tensorflow-emscripten

VERY MUCH A WORK IN PROGRESS & ACTIVE RESEARCH PROJECT -- DO NOT USE.
Apache License 2.0
56 stars 8 forks source link
browser-tensorflow emscripten machine-learning makefile tensorflow tensorflow-emscripten

tensorflow-emscripten

About

NOTE: This is still very much a work in progress, and not even fully operational. DO NOT DEPEND ON THIS PROJECT. I will post updates when it is working and stable.

This is a repository containing the source for Tensorflow (https://www.tensorflow.org/, pinned at version v0.12.0 currently) and slightly modified to be able to be compiled with Emscripten (https://kripken.github.io/emscripten-site/).

Install & Compiling

Requirements

Downloading files

Clone the repository. And download js-working-dir into ./tensorflow/contrib/makefile_js/js-working-dir.

Configuring the makefile

Open the makefile, ./tensorflow/contrib/makefile_js/Makefile, and you should see three options at the top which you are free to configure:

Making the library

Once you have configured the make file, run the following from the root of the repository:

$ emconfigure ./configure
$ ./tensorflow/contrib/makefile_js/download_dependencies.sh
$ bazel build tensorflow/examples/label_image/...
$ ./tensorflow/contrib/makefile_js/gen_file_lists.sh
$ emmake make -f ./tensorflow/contrib/makefile_js/Makefile

NOTE: Must run configure before download dependencies because otherwise the configure script will see build files in downloads and assume it should run those. Problem documented here. The bazel command is required to be run so that tensorflow generates certain source files, there is probably a simpler build for bazel, but we found this one to work.

TIP: Considering adding the flag '-jX' to the emmake command, which will multithread compilation with X threads.

This will generate (the file extensions depend on the FINAL_PRODUCT flag specified above):

Running the generated files

To run these files, use the run scripts; for example:

$ cd ./tensorflow/contrib/makefile_js/
$ ./run_scripts/run_labeler_c.sh 0

(That will call the labeler script on makefile_js/js-working-dir/labeler_data/0.jpg).

Read through run_scripts/*.sh, to figure out how to call the libraries on their own.

Misc

$ cd ./tensorflow/contrib/makefile_js/
$ python run_trails.py {mnist,labeler} {browser,node,c}

(Which will benchmark mnist/labeler in the browser/node/c.)

TODOs / Known Issues

Author

Tomas Reimers, September 2016 - February 2017