-
Notifications
You must be signed in to change notification settings - Fork 675
Vacc Backend #1679
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
Merged
Merged
Vacc Backend #1679
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1cb7f38
[Enhancement] Support vacc backend
AndyLiu93 3085f3d
update vacc wrapper
AndyLiu93 698b126
vacc docs
AndyLiu93 e48a25f
update vacc docs and remove some comments
AndyLiu93 bab68a8
update vacc backend configs
AndyLiu93 99aa775
get vacc_det real output
AndyLiu93 6cc2384
Fix vacc: pre-commit run
AndyLiu93 c31acea
fix pre-commit
AndyLiu93 9eff031
update vacc quantize
AndyLiu93 ac1091f
update vacc docs.
AndyLiu93 5e3df1b
update vacc docs.
AndyLiu93 831b4da
[Fix]vacc wrapper and support set calib_num
AndyLiu93 07d5c7d
add vacc_seg model_type
AndyLiu93 240bcf8
update vacc_det type
AndyLiu93 fee2f6d
update vacc_det type
AndyLiu93 b19465f
fix typo
AndyLiu93 da5a751
[Fix] some typo
AndyLiu93 b3d9865
feats: update mmseg vacc sample
AndyLiu93 25e217b
feats: update mmseg vacc sample
AndyLiu93 dd4459f
feats: update mmdet vacc sample
AndyLiu93 0814da0
feats: update vacc quant_dataset func.
AndyLiu93 67c8ca7
update vacc wrapper exit-code
AndyLiu93 212be29
update vacc segmentor setting
AndyLiu93 f250328
update vacc seg base_decode_head rewriter
AndyLiu93 e80c15b
fix vacc wrapper outputs
AndyLiu93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
backend_config = dict( | ||
type='vacc', | ||
common_config=dict(name='end2end', model_info=None, vdsp_params_info=None), | ||
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=[], | ||
)) | ||
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_base_ = ['./classification_static.py', '../_base_/backends/vacc.py'] | ||
|
||
backend_config = dict( | ||
common_config=dict( | ||
model_info='/path/to/model_info.json', | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
vdsp_params_info='/path/to/vdsp_params_info.json'), | ||
model_inputs=[ | ||
dict(shape=dict(input=[1, 3, 224, 224]), qconfig=dict(dtype='fp16')) | ||
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) | ||
]) |
20 changes: 20 additions & 0 deletions
20
configs/mmdet/detection/detection_vacc-fp16_static_416x416.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
_base_ = ['../_base_/base_static.py', '../../_base_/backends/vacc.py'] | ||
|
||
backend_config = dict( | ||
common_config=dict( | ||
model_info='/path/to/model_info.json', | ||
vdsp_params_info='/path/to/vdsp_params_info.json'), | ||
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)]) | ||
]) |
16 changes: 16 additions & 0 deletions
16
configs/mmdet/detection/detection_vacc-int8_static_416x416.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
_base_ = ['../_base_/base_static.py', '../../_base_/backends/vacc.py'] | ||
|
||
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)]) | ||
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
_base_ = ['./segmentation_static.py', '../_base_/backends/vacc.py'] | ||
|
||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
backend_config = dict(model_inputs=[dict(shape=dict(input=[1, 3, 512, 512]))]) | ||
|
||
partition_config = dict( | ||
type='end2end', | ||
apply_marks=True, | ||
partition_cfg=[ | ||
dict( | ||
save_file='model.onnx', | ||
start=['segmentor_forward:output'], | ||
end=['seg_maps:input'], | ||
output_names=['feat']) | ||
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
_base_ = ['./segmentation_static.py', '../_base_/backends/vacc.py'] | ||
|
||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
backend_config = dict(model_inputs=[ | ||
dict(shape=dict(input=[1, 3, 512, 512]), qconfig=dict(dtype='int8')) | ||
]) | ||
|
||
partition_config = dict( | ||
type='end2end', | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
apply_marks=True, | ||
partition_cfg=[ | ||
dict( | ||
save_file='model.onnx', | ||
start=['segmentor_forward:output'], | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end=['decode_head:input'], | ||
output_names=['feat']) | ||
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# 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 -r requirements.txt | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### step.2 | ||
|
||
```bash | ||
sudo vi ~/.bashrc | ||
|
||
export VASTSTREAM_PIPELINE=true | ||
export VACC_IRTEXT_ENABLE=1 | ||
export TVM_HOME="/opt/vastai/vaststream/tvm" | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# 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 -r requirements.txt | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### 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 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
AndyLiu93 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from mmdeploy.backend.vacc import from_onnx as _from_onnx | ||
from_onnx = PIPELINE_MANAGER.register_pipeline()(_from_onnx) | ||
__all__ += ['from_onnx'] | ||
except Exception: | ||
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
from .backend_manager import VACCManager | ||
from .onnx2vacc import from_onnx | ||
|
||
_BackendManager = VACCManager | ||
|
||
is_available = _BackendManager.is_available | ||
build_wrapper = _BackendManager.build_wrapper | ||
|
||
__all__ = ['VACCManager', 'from_onnx'] | ||
|
||
if is_available(): | ||
try: | ||
from .wrapper import VACCWrapper | ||
|
||
__all__ += ['VACCWrapper'] | ||
except Exception: | ||
pass |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.