Skip to content

Commit

Permalink
Merge pull request #949 from BUG1989/add_doc
Browse files Browse the repository at this point in the history
add the doc with superedge
  • Loading branch information
daquexian authored Jul 28, 2021
2 parents d8fba09 + 6dc0f0a commit ecff02d
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Tengine 核心代码由 4 个模块组成:

### 量化工具

- [源码编译](tools/quantize/README.md):已开源量化工具源码,已支持uint8/int8。
- [源码编译](tools/quantize/README.md):已开源量化工具源码,已支持 uint8/int8。

### 速度评估

Expand All @@ -66,7 +66,12 @@ Tengine 核心代码由 4 个模块组成:
- [TIM-VX](doc/npu_tim-vx_user_manual.md) VeriSilicon NPU 使用指南。

### AutoKernel Plugin
- [AutoKernel](https://github.com/OAID/AutoKernel.git) 是一个简单易用,低门槛的自动算子优化工具,AutoKernel Plugin实现了自动优化算子一键部署到Tengine中。

- [AutoKernel](https://github.com/OAID/AutoKernel.git) 是一个简单易用,低门槛的自动算子优化工具,AutoKernel Plugin实现了自动优化算子一键部署到 Tengine 中。

### Container

- [SuperEdge](https://github.com/superedge/superedge) 借助 SuperEdge 边缘计算的开源容器管理系统,提供更便捷的业务管理方案:[How to use Tengine with SuperEdge](doc/superedge_user_manual.md)

## Roadmap

Expand All @@ -88,6 +93,7 @@ Tengine Lite 参考和借鉴了下列项目:
- [stb](https://github.com/nothings/stb)
- [convertmodel](https://convertmodel.com)
- [TIM-VX](https://github.com/VeriSilicon/TIM-VX)
- [SuperEdge](https://github.com/superedge/superedge)

## License

Expand Down
13 changes: 13 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ The core code of Tengine Lite consists of 4 modules:

- [Benchmark](benchmark/) Basic network speed assessment tool, any pull request is welcomed.

### NPU Plugin

- [TIM-VX](doc/npu_tim-vx_user_manual.md) VeriSilicon NPU user manual.

### AutoKernel Plugin

- [AutoKernel](https://github.com/OAID/AutoKernel.git).

### Container

- [SuperEdge](https://github.com/superedge/superedge) [How to use Tengine with SuperEdge](doc/superedge_user_manual.md).

## Roadmap

- [Road map](doc/roadmap.md)
Expand All @@ -80,6 +92,7 @@ Tengine Lite got ideas and developed based on these projects:
- [stb](https://github.com/nothings/stb)
- [convertmodel](https://convertmodel.com)
- [TIM-VX](https://github.com/VeriSilicon/TIM-VX)
- [SuperEdge](https://github.com/superedge/superedge)

## License

Expand Down
106 changes: 106 additions & 0 deletions doc/demo_videocapture_user_manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Tengine Video Capture User Manual



## 约束

当前版本仅支持基于 Khadas VIM3 SBC 上的 NPU 网络模型推理演示,我们后续会逐步完善,支持基于更多硬件平台的功能演示。

默认大家手上的 Khadas VIM3 中的固件为最新版本。

### 硬件说明

| 物品 | 描述 |
| ----------- | ------------------------------------------------------------ |
| Khadas VIM3 | 内置 A311D SoC 的单板计算机,内置 5Tops NPU 加速器 |
| USB 摄像头 | 输入实时视频流 |
| 液晶显示器 | 控制台操作,实时输出示例运行结果 |
| HDMI连接线 | 由于Khadas VIM3 的 TYPE C 接口与 HDMI 接口过于紧凑,需要寻找小一点接口的 HMDI 连接线 |

### 软件说明

以下均为 Khadas VIM3 单板计算机上的软件描述。

- Ubuntu 20.04
- OpenCV 4.2
- gcc 9.3.0
- cmake 3.16.3

### 操作说明

后续步骤中的命令行操作均为基于 Khadas VIM3 单板计算机上的操作,其中:

- **下载****编译**步骤 可以过 SSH 登陆或者直接在 Khadas VIM3 的 UBuntu 桌面启动控制台中执行;
- **运行**步骤仅在 Khadas VIM3 的 UBuntu 桌面启动控制台中执行。

## 编译

### 下载 NPU 依赖库 TIM-VX

```
$ git clone https://github.com/VeriSilicon/TIM-VX.git
```

### 下载 Tengine

```
$ git clone https://github.com/OAID/Tengine.git tengine-lite
$ cd tengine-lite
```

### 准备代码

```
$ cd <tengine-lite-root-dir>
$ cp -rf ../TIM-VX/include ./source/device/tim-vx/
$ cp -rf ../TIM-VX/src ./source/device/tim-vx/
```

### 执行编译

```
$ cd <tengine-lite-root-dir>
$ mkdir build && cd build
$ cmake -DTENGINE_ENABLE_TIM_VX=ON -DTENGINE_ENABLE_MODEL_CACHE=ON -DTENGINE_BUILD_DEMO=ON ..
$ make demo_yolo_camera -j`nproc`
```

编译完成后,`libtengine-lite.so``demo_yolo_camera` 存放在以下路径:

- `<tengine-lite-root-dir>/build/source/libtengine-lite.so`
- `<tengine-lite-root-dir>/build/demos/demo_yolo_camera`

## 运行

模型文件 `yolov3_uint8.tmfile` 可从 Model ZOO 中下载,按照以下顺序方式存放文件:

```
......
├── demo_yolo_camera
├── libtengine-lite.so
├── models
│   └── yolov3_uint8.tmfile
......
```

执行当前路径下的 `demo_yolo_camera`

```
./demo_yolo_camera
```

*P.S. :第一次运行因为会在线编译生成 NPU 运行依赖的 kernel file,会有一定的等待时间(大约30秒),后续运行直接加载所在目录下的 cache file 文件(小于1秒)。*

## 关于容器

- 我们提供了基于 Khadas VIM3 平台的容器版本,具体操作可以参考 [superedge_user_manual](./superedge_user_manual.md)
- 我们提供了腾讯云的 SuperEdge 版本,请参考(待补充)。



## FAQ

Khadas VIM3 编译 Tengine + TIMVX 其余问题(包括 Khadas VIM3 购买渠道)可以参考 [npu_tim-vx_user_manual_zh](./npu_tim-vx_user_manual_zh.md)



122 changes: 122 additions & 0 deletions doc/superedge_user_manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# [SuperEdge](https://github.com/superedge/superedge "SuperEdge") & [Tengine](https://github.com/OAID/Tengine "Tengine")

------------
## Quickstart Guide
### Install edge Kubernetes master node

```shell
wget http://tengine2.openailab.com:9527/openailab/edgeadm-linux-amd64-v0.4.0.tgz
tar -zxvf edgeadm-linux-amd64-v0.4.0.tgz
cd edgeadm-linux-amd64-v0.4.0
./edgeadm init --kubernetes-version=1.18.2 --image-repository superedge.tencentcloudcr.com/superedge --service-cidr=10.96.0.0/12 --pod-network-cidr=10.224.0.0/16 --install-pkg-path ./kube-linux-*.tar.gz --apiserver-cert-extra-sans=<Master Public IP> --apiserver-advertise-address=<Master Intranet IP> --enable-edge=true
```
### Join edge node

```shell
wget http://tengine2.openailab.com:9527/openailab/edgeadm-linux-arm64-v0.4.0.tgz
tar -zxvf edgeadm-linux-arm64-v0.4.0.tgz
cd edgeadm-linux-arm64-v0.4.0
./edgeadm join <Master Public/Intranet IP Or Domain>:Port --token xxxx --discovery-token-ca-cert-hash sha256:xxxxxxxxxx --install-pkg-path kube-linux-arm64-v1.18.2.tar.gz --enable-edge=true
```
### Build Docker images on Khadas VIM3 Device

```shell
wget http://tengine2.openailab.com:9527/openailab/yolo.tar.gz
tar -zxvf yolo.tar.gz
cd superedge
docker build -t yolo:latest .
```
Dockerfile
```
FROM ubuntu:20.04
MAINTAINER openailab
RUN apt-get update
RUN apt-get install -y tzdata
RUN apt-get install -y libopencv-dev
RUN apt-get install -y libcanberra-gtk-module
RUN useradd -m openailab
COPY libtengine-lite.so /root/myapp/
COPY demo_yolo_camera /root/myapp/
COPY tm_330_330_330_1_3.tmcache /root/myapp/
ADD models /root/myapp/models/
COPY tm_88_88_88_1_1.tmcache /root/myapp/
COPY tm_classification_timvx /root/myapp/
COPY libOpenVX.so /lib/
COPY libGAL.so /lib/
COPY libVSC.so /lib/
COPY libArchModelSw.so /lib/
COPY libNNArchPerf.so /lib/
COPY libgomp.so.1 /lib/aarch64-linux-gnu/
COPY libm.so.6 /lib/aarch64-linux-gnu/
WORKDIR /root/myapp/
USER openailab
CMD ["./demo_yolo_camera"]
```
[Tengine lite source code Download](http://www.baidu.com "Tengine lite source code Download")

### RUN yolo docker container on Khadas VIM3 Device

```shell
# Access to Xserver
# Execute script on device Terminal
xhost +
# Run
docker run -it --name yolo --privileged -v /dev:/dev -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=:0 -e GDK_SCALE -e GDK_DPI_SCALE yolo:latest
```
### Deploy yolo with SuperEdge

Edit yolo.yaml

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: yolo
labels:
name: yolo
spec:
replicas: 1
selector:
matchLabels:
name: yolo
template:
metadata:
labels:
name: yolo
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- khadas
containers:
- name: yolo
image: registry.cn-shenzhen.aliyuncs.com/edge_studio/yolo:v1.0
env:
- name: DISPLAY
value: :0
volumeMounts:
- name: dev
mountPath: /dev
- name: unix
mountPath: /tmp/.X11-unix
securityContext:
privileged: true
volumes:
- name: dev
hostPath:
path: /dev
- name: unix
hostPath:
path: /tmp/.X11-unix
```
## Deploy yolo App
```shell
kubectl apply -f yolo.yaml
```
![](http://tengine2.openailab.com:9527/openailab/yolo_demo.jpg)

0 comments on commit ecff02d

Please sign in to comment.