Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: flake8
args: ["--exclude=*/client/inference_pb2.py,*/client/inference_pb2_grpc.py"]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-yapf
Expand Down
17 changes: 17 additions & 0 deletions configs/_base_/backends/vacc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
backend_config = dict(
type='vacc',
common_config=dict(name='end2end'),
model_inputs=[
dict(
shape=dict(input=[1, 3, 224, 224]),
qconfig=dict(
dtype='fp16',
calibrate_mode='percentile',
weight_scale='max',
data_transmode=1,
per_channel=False,
cluster_mode=0,
skip_conv_layers=[],
calib_num=1000,
))
])
26 changes: 26 additions & 0 deletions configs/mmcls/classification_vacc-fp16_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
_base_ = ['./classification_static.py', '../_base_/backends/vacc.py']

backend_config = dict(
common_config=dict(
vdsp_params_info=dict(
vdsp_op_type=300,
iimage_format=5000,
iimage_width=256,
iimage_height=256,
iimage_width_pitch=256,
iimage_height_pitch=256,
short_edge_threshold=256,
resize_type=1,
color_cvt_code=2,
color_space=0,
crop_size=224,
meanr=22459,
meang=22340,
meanb=22136,
stdr=21325,
stdg=21284,
stdb=21292,
norma_type=3)),
model_inputs=[
dict(shape=dict(input=[1, 3, 224, 224]), qconfig=dict(dtype='fp16'))
])
5 changes: 5 additions & 0 deletions configs/mmcls/classification_vacc-int8_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_base_ = ['./classification_static.py', '../_base_/backends/vacc.py']

backend_config = dict(model_inputs=[
dict(shape=dict(input=[1, 3, 224, 224]), qconfig=dict(dtype='int8'))
])
43 changes: 43 additions & 0 deletions configs/mmdet/detection/detection_vacc-fp16_static_416x416.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
_base_ = ['../_base_/base_static.py', '../../_base_/backends/vacc.py']

onnx_config = dict(input_shape=[416, 416])

backend_config = dict(
common_config=dict(
vdsp_params_info=dict(
vdsp_op_type=303,
iimage_format=5000,
iimage_width=640,
iimage_height=640,
oimage_width=416,
oimage_height=416,
iimage_width_pitch=640,
iimage_height_pitch=640,
resize_type=1,
color_cvt_code=2,
color_space=0,
padding_value_r=114,
padding_value_g=114,
padding_value_b=114,
edge_padding_type=0,
meanr=0,
meang=0,
meanb=0,
stdr=23544,
stdg=23544,
stdb=23544,
norma_type=3)),
model_inputs=[
dict(shape=dict(input=[1, 3, 416, 416]), qconfig=dict(dtype='fp16'))
])

partition_config = dict(
type='vacc_det',
apply_marks=True,
partition_cfg=[
dict(
save_file='model.onnx',
start=['detector_forward:input'],
end=['yolo_head:input'],
output_names=[f'pred_maps.{i}' for i in range(3)])
])
18 changes: 18 additions & 0 deletions configs/mmdet/detection/detection_vacc-int8_static_416x416.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
_base_ = ['../_base_/base_static.py', '../../_base_/backends/vacc.py']

onnx_config = dict(input_shape=[416, 416])

backend_config = dict(model_inputs=[
dict(shape=dict(input=[1, 3, 416, 416]), qconfig=dict(dtype='int8'))
])

partition_config = dict(
type='vacc_det',
apply_marks=True,
partition_cfg=[
dict(
save_file='model.onnx',
start=['detector_forward:input'],
end=['yolo_head:input'],
output_names=[f'pred_maps.{i}' for i in range(3)])
])
41 changes: 41 additions & 0 deletions configs/mmseg/segmentation_vacc-fp16_static_512x512.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
_base_ = ['./segmentation_static.py', '../_base_/backends/vacc.py']

onnx_config = dict(input_shape=[512, 512])

backend_config = dict(
common_config=dict(
vdsp_params_info=dict(
vdsp_op_type=301,
iimage_format=5000,
iimage_width=512,
iimage_height=512,
oimage_width=512,
oimage_height=512,
iimage_width_pitch=512,
iimage_height_pitch=512,
resize_type=1,
color_cvt_code=2,
color_space=0,
meanr=22459,
meang=22340,
meanb=22136,
stdr=21325,
stdg=21284,
stdb=21292,
norma_type=3)),
model_inputs=[dict(shape=dict(input=[1, 3, 512, 512]))])

codebase_config = dict(model_type='vacc_seg')

partition_config = dict(
type='vacc_seg',
apply_marks=True,
partition_cfg=[
dict(
save_file='model.onnx',
start=['segmentor_forward:output'],
# 'decode_head' will skip `ArgMax`
# 'seg_maps' will skip `Resize` and `ArgMax`
end=['decode_head:input'],
output_names=['feat'])
])
20 changes: 20 additions & 0 deletions configs/mmseg/segmentation_vacc-int8_static_512x512.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
_base_ = ['./segmentation_static.py', '../_base_/backends/vacc.py']

onnx_config = dict(input_shape=[512, 512])

backend_config = dict(model_inputs=[
dict(shape=dict(input=[1, 3, 512, 512]), qconfig=dict(dtype='int8'))
])

partition_config = dict(
type='vacc_seg',
apply_marks=True,
partition_cfg=[
dict(
save_file='model.onnx',
start=['segmentor_forward:output'],
# 'decode_head' will skip `ArgMax`
# 'seg_maps' will skip `Resize` and `ArgMax`
end=['decode_head:input'],
output_names=['feat'])
])
95 changes: 95 additions & 0 deletions docs/en/05-supported-backends/vacc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# VACC Backend

- cmake 3.10.0+
- gcc/g++ 7.5.0
- llvm 9.0.1
- ubuntu 18.04

## PCIE

### 1.package

- dkms (>=1.95)
- linux-headers
- dpkg (Ubuntu)
- rpm (CentOS)
- python2
- python3

Check if there is a vacc card:`lspci -d:0100`

1. Requirements

```bash
sudo apt-get install dkms dpkg python2 python3
```

2. install driver

```bash
sudo dpkg -i vastai-pci_xx.xx.xx.xx_xx.deb
```

3. Verify installation

```bash
dpkg --status vastai-pci-xxx

#output
Package: vastai-pci-dkms
Status: install ok installed
……
Version: xx.xx.xx.xx
Provides: vastai-pci-modules (= xx.xx.xx.xx)
Depends: dkms (>= 1.95)
Description: vastai-pci driver in DKMS format.

lsmod | grep vastai_pci

#output
vastai_pci xxx x
```

4. Upgrade driver

```bash
sudo dpkg -i vastai-pci_dkms_xx.xx.xx.xx_xx.deb
```

5. Uninstall driver

```bash
sudo dpkg -r vastai-pci_dkms_xx.xx.xx.xx_xx
```

### 2.reboot pcie

```bash
sudo chmod 666 /dev/kchar:0 && sudo echo reboot > /dev/kchar:0
```

## SDK

### step.1

```bash
pip install torch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0
pip install onnx==1.10.0 tqdm==4.64.1
pip install h5py==3.8.0
pip install decorator==5.1.1 scipy==1.7.3
```

### step.2

```bash
sudo vi ~/.bashrc

export VASTSTREAM_PIPELINE=true
export VACC_IRTEXT_ENABLE=1
export TVM_HOME="/opt/vastai/vaststream/tvm"
export VASTSTREAM_HOME="/opt/vastai/vaststream/vacl"
export LD_LIBRARY_PATH=$TVM_HOME/lib:$VASTSTREAM_HOME/lib
export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/vacc/python:$TVM_HOME/topi/python:${PYTHONPATH}:$VASTSTREAM_HOME/python

source ~/.bashrc
```
97 changes: 97 additions & 0 deletions docs/zh_cn/05-supported-backends/vacc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# VACC Backend

- cmake 3.10.0+
- gcc/g++ 7.5.0
- llvm 9.0.1
- ubuntu 18.04

## PCIE

### 1.package

- dkms (>=1.95)
- linux-headers
- dpkg (Ubuntu)
- rpm (CentOS)
- python2
- python3

查看是否有瀚博推理卡:`lspci -d:0100`

1. 环境准备

```bash
sudo apt-get install dkms dpkg python2 python3
```

2. driver安装

```bash
sudo dpkg -i vastai-pci_xx.xx.xx.xx_xx.deb
```

3. 查看安装

```bash
# 1.查看deb包是否安装成功
dpkg --status vastai-pci-xxx

#output
Package: vastai-pci-dkms
Status: install ok installed
……
Version: xx.xx.xx.xx
Provides: vastai-pci-modules (= xx.xx.xx.xx)
Depends: dkms (>= 1.95)
Description: vastai-pci driver in DKMS format.

# 2.查看驱动是否已加载到内核
lsmod | grep vastai_pci

#output
vastai_pci xxx x
```

4. 升级驱动

```bash
sudo dpkg -i vastai-pci_dkms_xx.xx.xx.xx_xx.deb
```

5. 卸载驱动

```bash
sudo dpkg -r vastai-pci_dkms_xx.xx.xx.xx_xx
```

### 2.reboot pcie

```bash
sudo chmod 666 /dev/kchar:0 && sudo echo reboot > /dev/kchar:0
```

## SDK

### step.1

```bash
pip install torch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0
pip install onnx==1.10.0 tqdm==4.64.1
pip install h5py==3.8.0
pip install decorator==5.1.1 scipy==1.7.3
```

### step.2

```bash
sudo vi ~/.bashrc

export VASTSTREAM_PIPELINE=true
export VACC_IRTEXT_ENABLE=1
export TVM_HOME="/opt/vastai/vaststream/tvm"
export VASTSTREAM_HOME="/opt/vastai/vaststream/vacl"
export LD_LIBRARY_PATH=$TVM_HOME/lib:$VASTSTREAM_HOME/lib
export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/vacc/python:$TVM_HOME/topi/python:${PYTHONPATH}:$VASTSTREAM_HOME/python

source ~/.bashrc
```
13 changes: 13 additions & 0 deletions mmdeploy/apis/vacc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmdeploy.backend.vacc import is_available
from ..core import PIPELINE_MANAGER

__all__ = ['is_available']

if is_available():
try:
from mmdeploy.backend.vacc import from_onnx as _from_onnx
from_onnx = PIPELINE_MANAGER.register_pipeline()(_from_onnx)
__all__ += ['from_onnx']
except Exception:
pass
Loading