How to Install TensorFlow Lite
Building TensorFlow Lite from Source
Tested Operating Systems
This instructions have been tested on:
- Ubuntu Xenial 16.04
- Ubuntu Bionic 18.04
- Elementary Hera 5.1
TensorFlow Lite dependencies
sudo apt install git wget unzip python3 curl build-essential zlib1g-dev python3-numpy python3-six # Some TF tools assume python is pointing to python3 # This uses the update-alternative util to do so. Caution, # verify you don't have an alternative already configured # by running "update-alternatives --config python" # sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Configuration Variables
TF_VERSION=v2.0.1
TensorFlow Lite Build Steps
git clone https://github.com/tensorflow/tensorflow.git cd tensorflow # Move to a stable version git checkout $TF_VERSION # Important - download a valid bazel version BAZEL=`awk -F"'" '/_TF_MAX_BAZEL_VERSION = /{print $2}' configure.py` mkdir bazel cd bazel wget -c https://github.com/bazelbuild/bazel/releases/download/${BAZEL}/bazel-${BAZEL}-installer-linux-x86_64.sh chmod +x bazel-${BAZEL}-installer-linux-x86_64.sh sudo ./bazel-${BAZEL}-installer-linux-x86_64.sh cd .. # Configure tensorflow - I usually accept all defaults ./configure # Build the library cd tensorflow/lite/tools/make ./download_dependencies.sh ./build_lib.sh cd ../../../.. # The library will be built here realpath tensorflow/lite/tools/make/gen/linux_x86_64/lib/libtensorflow-lite.a
Benchmarking a TensorFlow Lite Model
Make sure you've run the previous steps already.
# Configure tensorflow (if you havent already)- I usually accept all defaults ./configure # Finally build the benchmarking tool bazel build -c opt tensorflow/lite/tools/benchmark:benchmark_model # Run the benchmarking bazel-bin/tensorflow/lite/tools/benchmark/benchmark_model \ --graph=mobilenet_quant_v1_224.tflite \ --num_threads=4
RidgeRun Resources | |||||
Contact Us
|