Create Docker to use Edge TPU compiler

Introduction

Edge TPU can be used on Mac and Windows as well as Raspberry Pi, but it seems that it can be compiled only on Debian-based Linux, so I made it possible to compile using Docker so that it can also be compiled on Mac and Windows.

Creating a Dockerfile

Create the following as a Dockerfile


FROM debian:buster-slim

RUN export DEBIAN_FRONTEND=noninteractive \
 && apt-get update \
 && apt-get install --no-install-recommends -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
 && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
 && echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list \
 && apt-get update \
 && apt-get install edgetpu-compiler \

WORKDIR /home/edgetpu-compiler

ENTRYPOINT ["edgetpu_compiler"]

Docker build Build the created Dockerfile with the following command

docker image build -t edgetpu-compiler .

Preparation of quantization model

Create a directory in the same directory as dockerfile


mkdir model

Store the tflite quantized with INT8 in the model directory.

Edge TPU compilation

Compile the tflite model quantized with INT8 into a model for Edeg TPU with the following command

docker run --rm -it -v $(pwd):/home/edgetpu-compiler edgetpu-compiler model/{MODEL}

For the {MODEL} part, specify the tflite quantized by INT8 prepared earlier. If files like {MODEL} _edgetpu.log and {MODEL} _edgetpu.tflite are created, you should have successfully compiled.

Finally

Even if you don't have a Linux environment, you can easily compile it into a model for EdgeTPU on Mac or Windows and infer it with EdgeTPU.

reference

This article was written with reference to the following information. -Use Edge TPU compiler on Docker container

Recommended Posts

Create Docker to use Edge TPU compiler
[Artifactory] How to use Docker repository
Make a C compiler to use with Rust x CLion with Docker
Use Jenkins to build inside Docker and then create a Docker image.
[For those who create portfolios] How to use binding.pry with Docker
[Rails] How to use rails console with docker
[Docker] Building an environment to use Hugo
How to use Docker in VSCode DevContainer
Try to use docker command without sudo.
Understand in 5 minutes !! How to use Docker
How to use docker compose with NVIDIA Jetson
How to use nginx-ingress-controller with Docker for Mac
[Introduction to Docker] Create a Docker image for machine learning and use Jupyter notebook
Create a Docker container to convert EPS to PGF source
[For those who create portfolios] How to use font-awesome-rails
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use java.util.logging
How to use map
Why we use Docker
PATH to use docker-slim
Use Puphpeteer with Docker
How to use Twitter4J
How to use active_hash! !!
How to install Docker
How to use hidden_field_tag
[How to use label]
How to use identity
How to use hashes
Use ngrok with Docker
How to create docker-compose
How to use JUnit 5
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to use Map
How to create a placeholder part to use in the IN clause
[For those who create portfolios] How to use chart kick
I tried to create React.js × TypeScript × Material-UI on docker environment
How to use mysql with M1 mac Docker preview version
I tried to create a padrino development environment with Docker
Study Java: Use Timer to create something like a bomb timer
[Enum_help] Use enum_help to create a select box displayed in Japanese!
You are required to use winpty with docker exec [Windows]