Skip to content

Commit 39b1e37

Browse files
author
Peyton Chandarana
authored
Merge pull request #1 from iCAS-Lab/init
Init repo with edge device setups
2 parents f89afcc + 29c7103 commit 39b1e37

19 files changed

+1076
-2
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 iCAS-Lab
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,56 @@
11
# Edge ML Accelerators
2+
23
This repository contains the code, scripts, and Dockerfiles for setting up different edge machine learning accelerators on different platforms.
4+
5+
## Required Software:
6+
7+
- A computer with an Intel/AMD x86-64 CPU running a 64-bit version of Linux with sudo priveleges (other OSes not tested).
8+
- [Docker](https://docs.docker.com/engine/install/)
9+
10+
- See [A Note on Docker](#a-note-on-docker) and [Installing Docker](#installing-docker)
11+
- For the Intel NCS2, Google Coral Edge TPU, and flashing the NVIDIA Jetson Nano.
12+
- Optional to install on Raspberry Pi.
13+
- Installed by default on Jetson Nano via SDK Manager.
14+
15+
- Internet Access to install software dependencies.
16+
17+
## Required Hardware:
18+
19+
Each device has its own requirements for cables, power supplies, and etc. These are listed in the `Required Hardware` sections of each device. The following are general requirements:
20+
21+
- Mouse, keyboard, and monitor (Raspberry Pi and Jetson Nano)
22+
- A host computer with a CPU (Intel NCS2 and Google Coral Edge TPU)
23+
24+
## Device Setup Documentation
25+
26+
- [coraltpu](./coraltpu) - Google Coral Edge TPU setup instructions.
27+
- [jetson](./jetson) - NVIDIA Jetson Nano (2GB and 4GB) setup instructions.
28+
- [ncs2](./ncs2/) - Intel Neural Computer Stick 2 setup instructions.
29+
- [raspberrypi](./raspberrypi) - Raspberry Pi setup instructions.
30+
31+
## A Note on Docker
32+
33+
Docker is a containerization software that is able to isolate applications and even operating systems. The idea of containers is similar to a Virtual Machine (VM), but without the hypervisor i.e. emulating the hardware which resource demanding. Instead, containers are able to directly work with the computer's hardware and kernel for making more efficient use of system resources than a VM.
34+
35+
Theoretically, all of these devices should work independent of using Docker and in many cases we observed they could. However, for the simplest setup, we recommend using Docker to prevent compatibility issues with your host computer's OS.
36+
37+
Many of the devices require sudo priveleges to install packages and to access the hardware directly. Thus, when running the docker image many of the commands use the `--priveleged` flag. **_Using this flag can have certain negative security implications._** Please use this with care.
38+
39+
## Installing Docker
40+
41+
Use the instructions from Docker's official documentation to install docker on your computer.
42+
43+
- Ubuntu:
44+
45+
- https://docs.docker.com/engine/install/ubuntu/
46+
47+
- All other OS's:
48+
- https://docs.docker.com/get-docker/
49+
50+
Be sure to run `sudo docker run hello-world` to be sure your docker install was successful.
51+
52+
**_Note: You may need to use `sudo docker` to elevate permission on some OSes. You can avoid using `sudo` by adding your username to the `docker` group via the following command and logging out and back in:_**
53+
54+
```shell
55+
sudo usermod -aG docker username
56+
```

coraltpu/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Google Coral Edge TPU
2+
3+
Like the other devices we recommend using Docker to containerize this device's environment.
4+
5+
## 0. Preliminaries
6+
7+
### Required Software
8+
9+
It is **_HIGHLY_** recommended to use Docker to use the Coral Edge TPU to avoid installing installing the dependencies/packages on your host machine and possibly causing library/package conflicts. Docker isolates applications and/or operating systems from your host machine without much performance loss.
10+
11+
- [Docker](https://docs.docker.com/engine/install/) - Install for Linux, use the `server` installation instructions. Only Docker Engine is needed, Docker Desktop is optional. For example, for installation on Ubuntu use the [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/) instructions.
12+
13+
### Required Hardware
14+
15+
- The Coral Edge TPU comes in two primary form factors that are commercially available from [here](https://coral.ai/products/). We have validated the following process on the USB form factor, but the process for other form factors should be similar. You will need to purchase one of the following devices:
16+
- [USB Accelerator](https://coral.ai/products/accelerator)
17+
- [Dev Board](https://coral.ai/products/dev-board) - 1GB and 4GB memory options available.
18+
- Host computer with a CPU and a Linux-based OS installed.
19+
20+
# Using via Docker (Recommened)
21+
22+
## 1. Download the Docker Image
23+
24+
Run the following command to pull the pre-configured Docker image:
25+
26+
```shell
27+
docker pull s7117/ubuntu-coraltpu:latest
28+
```
29+
30+
This Docker image contains the necessary packages pre-installed to run models on the Coral Edge TPU. For more details on what the image currently contains, see the Dockerfile [here](https://github.com/s7117/docker-envs/blob/main/coraltpu/Dockerfile).
31+
32+
## 2. Using the Docker Image
33+
34+
To use the Docker image run the following command replacing `container_name` and `hostname` with your desired strings (i.e. coraltpu or etc.).
35+
36+
```shell
37+
docker run --privileged -v /dev/bus/usb:/dev/bus/usb --name container_name --hostname hostname -ti s7117/ubuntu-coraltpu
38+
```
39+
40+
## 3. Copying to/from Docker Container
41+
42+
To copy a ML model or file(s) to the Docker container (i.e. named whatever you replaced `container_name` with in the above command) use the following command:
43+
44+
```shell
45+
# This command copies a PyTorch model from the current directory on the
46+
# host computer into the container named container_name to the
47+
# /home/user directory
48+
docker cp ./model.pt container_name:/home/user
49+
```
50+
51+
To copy a file from the Docker container use something like:
52+
53+
```shell
54+
# This command copies a PyTorch model from the Docker container
55+
# to your home directory (~) on your host machine.
56+
docker cp container_name:/home/user/model.pt ~
57+
```
58+
59+
# Using on Host
60+
61+
If you would like to install the Coral Edge TPU dependencies and libaries on your local host machine, simply run the [setup.sh](./setup.sh) bash script.

coraltpu/setup.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
#!/bin/bash
2+
3+
sudo apt update
4+
sudo apt upgrade -y
5+
6+
################################################################################
7+
# Install Coral TPU
8+
################################################################################
9+
### Add Coral TPU keys
10+
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
11+
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
12+
################################################################################
13+
# Update the repository with the new keys
14+
sudo apt update
15+
# Install the libs and python3 interface
16+
sudo apt-get install libedgetpu1-std python3-pycoral -y

0 commit comments

Comments
 (0)