Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coral TPU framework install #521

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts.d/15_pkg_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ INSTALL_PACKAGES=(
net-tools # netstat
libffi-dev # for building docker-compose using pip
python3-coral-enviro # Coral environmental board
libusb-1.0-0 python3-pil python3-numpy libc++1 libc++abi1 libunwind8 libgcc1 # For Coral TPU
)

if [[ ${INSTALL_PACKAGES:-} ]] ; then
Expand Down
61 changes: 61 additions & 0 deletions scripts.d/19_install_coraltpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# As modified for use in treehouses

# Downloading and unpacking files
wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz
tar xzf edgetpu_api.tar.gz
cd edgetpu_api || exit 1

# Defining variables
# SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LIBEDGETPU_SRC="$PWD/libedgetpu/libedgetpu_arm32.so"
LIBEDGETPU_DST="/usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0"
UDEV_RULE_PATH="/etc/udev/rules.d/99-edgetpu-accelerator.rules"

# Installing device rule file

if [[ -f "${UDEV_RULE_PATH}" ]]; then
rm -f "${UDEV_RULE_PATH}"
fi

cp -p "$PWD/99-edgetpu-accelerator.rules" "${UDEV_RULE_PATH}"
udevadm control --reload-rules && udevadm trigger
echo "Updated rules"

# Installing Edge TPU runtime library
if [[ -f "${LIBEDGETPU_DST}" ]]; then
echo "File already exists. Replacing it..."
rm -f "${LIBEDGETPU_DST}"
fi

mkdir /usr/lib/arm-linux-gnueabihf
echo "Created arm-linux-gnueabihf directory"
cp -p "${LIBEDGETPU_SRC}" "${LIBEDGETPU_DST}"
echo "Copied EdgeTPU files"
ldconfig
echo "Updated libraries"

# Python API.
WHEEL="$(ls "$PWD/edgetpu-*-py3-none-any.whl" 2>/dev/null)"
if [ $? = 0 ]; then
python3 -m pip install --no-deps "${WHEEL}"
echo "Installed Python API"
fi

cd .. && rm -rf edgetpu_api && rm -f edgetpu_api.tar.gz || exit 1
echo "Leaving directory and removing files"