Skip to content

Commit 2fcc8dc

Browse files
authored
[Feature]: Add github workflow based on self hosted runner (#1751)
* add win10 workflow * update * update and add dockerfile * update script * add build docker image script * update * support cuda10.2 * update docker file * update build image tag * add release docker file * update release dockerfile * fix ncnn python build * test docker workflow * remove docker build workflow * fix comments * add conda-incubator * update build script and workflow * fix comments
1 parent 754c080 commit 2fcc8dc

File tree

9 files changed

+494
-70
lines changed

9 files changed

+494
-70
lines changed

.circleci/scripts/linux/build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
ARGS=("$@")
44

5-
cd mmdeploy
6-
MMDEPLOY_DIR=$(pwd)
5+
SCRIPT_DIR=$(cd `dirname $0`; pwd)
6+
MMDEPLOY_DIR=$SCRIPT_DIR/../../..
7+
8+
cd $MMDEPLOY_DIR
79
mkdir -p build && cd build
810
cmake .. -DMMDEPLOY_BUILD_SDK=ON -DMMDEPLOY_BUILD_TEST=ON -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
911
-DMMDEPLOY_BUILD_EXAMPLES=ON -DMMDEPLOY_BUILD_SDK_CSHARP_API=ON \
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/sh
2+
3+
set -e
4+
# print env
5+
#python3 tools/check_env.py
6+
backend=${1:-ort}
7+
device=${2:-cpu}
8+
current_dir=$(cd `dirname $0`; pwd)
9+
mmdeploy_dir=$current_dir/../../..
10+
cd $mmdeploy_dir
11+
12+
work_dir=$mmdeploy_dir/work_dir
13+
mkdir -p $work_dir $mmdeploy_dir/data
14+
15+
model_cfg=$work_dir/resnet18_8xb32_in1k.py
16+
checkpoint=$work_dir/resnet18_8xb32_in1k_20210831-fbbb1da6.pth
17+
sdk_cfg=configs/mmcls/classification_sdk_dynamic.py
18+
input_img=tests/data/tiger.jpeg
19+
20+
python3 -m mim download mmcls --config resnet18_8xb32_in1k --dest $work_dir
21+
22+
if [ $backend == "ort" ]; then
23+
deploy_cfg=configs/mmcls/classification_onnxruntime_dynamic.py
24+
model=$work_dir/end2end.onnx
25+
elif [ $backend == "trt" ]; then
26+
deploy_cfg=configs/mmcls/classification_tensorrt-fp16_dynamic-224x224-224x224.py
27+
model=$work_dir/end2end.engine
28+
elif [ $backend == "ncnn" ]; then
29+
deploy_cfg=configs/mmcls/classification_ncnn_static.py
30+
model="$work_dir/end2end.param $work_dir/end2end.bin"
31+
else
32+
echo "Unsupported Backend=$backend"
33+
exit
34+
fi
35+
36+
echo "------------------------------------------------------------------------------------------------------------"
37+
echo "deploy_cfg=$deploy_cfg"
38+
echo "model_cfg=$model_cfg"
39+
echo "checkpoint=$checkpoint"
40+
echo "device=$device"
41+
echo "------------------------------------------------------------------------------------------------------------"
42+
43+
python3 tools/deploy.py \
44+
$deploy_cfg \
45+
$model_cfg \
46+
$checkpoint \
47+
$input_img \
48+
--device $device \
49+
--work-dir $work_dir \
50+
--dump-info
51+
52+
if [ $backend == "trt" ]; then
53+
echo "Running onnx2tensorrt"
54+
python3 tools/onnx2tensorrt.py \
55+
$deploy_cfg \
56+
$work_dir/end2end.onnx \
57+
$work_dir/temp
58+
fi
59+
60+
# prepare dataset
61+
wget -P data/ https://github.com/open-mmlab/mmdeploy/files/9401216/imagenet-val100.zip
62+
unzip data/imagenet-val100.zip -d data/
63+
64+
echo "Running test with $backend"
65+
66+
python3 tools/test.py \
67+
$deploy_cfg \
68+
$model_cfg \
69+
--model $model \
70+
--device $device \
71+
--log2file $work_dir/test_ort.log \
72+
--speed-test \
73+
--log-interval 50 \
74+
--warmup 20 \
75+
--batch-size 8
76+
77+
echo "Running test with sdk"
78+
79+
# change topk for test
80+
sed -i 's/"topk": 5/"topk": 1000/g' work_dir/pipeline.json
81+
82+
python3 tools/test.py \
83+
$sdk_cfg \
84+
$model_cfg \
85+
--model $work_dir \
86+
--device $device \
87+
--log2file $work_dir/test_sdk.log \
88+
--speed-test \
89+
--log-interval 50 \
90+
--warmup 20 \
91+
--batch-size 8
92+
93+
# test profiler
94+
echo "Profile sdk model"
95+
python3 tools/profiler.py \
96+
$sdk_cfg \
97+
$model_cfg \
98+
./data \
99+
--model $work_dir \
100+
--device $device \
101+
--batch-size 8 \
102+
--shape 224x224
103+
104+
echo "All done"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<#
2+
.SYNOPSIS
3+
A helper script to test tools of MMDeploy Converter on windows.
4+
5+
.Description
6+
-Backend: support ort, trt
7+
-Device: support cpu, cuda, cuda:0
8+
9+
.EXAMPLE
10+
PS> .circleci/scripts/linux/test_full_pipeline.sh -Backend ort -Device cpu
11+
#>
12+
13+
param(
14+
[Parameter(Mandatory = $true)]
15+
[string] $Backend,
16+
[string] $Device
17+
)
18+
19+
$MMDeploy_DIR="$PSScriptRoot\..\..\.."
20+
Set-Location $MMDeploy_DIR
21+
22+
$work_dir="work_dir"
23+
New-Item -Path $work_dir, .\data -ItemType Directory -Force
24+
$model_cfg="$work_dir\resnet18_8xb32_in1k.py"
25+
$checkpoint="$work_dir\resnet18_8xb32_in1k_20210831-fbbb1da6.pth"
26+
$sdk_cfg="configs\mmcls\classification_sdk_dynamic.py"
27+
$input_img="tests\data\tiger.jpeg"
28+
29+
python -m mim download mmcls --config resnet18_8xb32_in1k --dest $work_dir
30+
31+
if ($Backend -eq "ort") {
32+
$deploy_cfg="configs\mmcls\classification_onnxruntime_dynamic.py"
33+
$model="$work_dir\end2end.onnx"
34+
} elseif ($Backend -eq "trt") {
35+
$deploy_cfg="configs\mmcls\classification_tensorrt-fp16_dynamic-224x224-224x224.py"
36+
$model="$work_dir\end2end.engine"
37+
} else {
38+
Write-Host "Unsupported Backend=$Backend"
39+
Exit
40+
}
41+
42+
Write-Host "--------------------------------------"
43+
Write-Host "deploy_cfg=$deploy_cfg"
44+
Write-Host "$model_cfg=$model_cfg"
45+
Write-Host "$checkpoint=$checkpoint"
46+
Write-Host "device=$device"
47+
Write-Host "--------------------------------------"
48+
49+
python tools\deploy.py `
50+
$deploy_cfg `
51+
$model_cfg `
52+
$checkpoint `
53+
$input_img `
54+
--device $device `
55+
--work-dir $work_dir `
56+
--dump-info
57+
58+
# prepare dataset
59+
Invoke-WebRequest -Uri https://github.com/open-mmlab/mmdeploy/files/9401216/imagenet-val100.zip -OutFile $pwd\data\imagenet-val100.zip
60+
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$pwd\data\imagenet-val100.zip", "$pwd\data\")
61+
62+
Write-Host "Running test with ort"
63+
python tools\test.py `
64+
$deploy_cfg `
65+
$model_cfg `
66+
--model $model `
67+
--device $device `
68+
--log2file $work_dir\test_ort.log `
69+
--speed-test `
70+
--log-interval 50 `
71+
--warmup 20 `
72+
--batch-size 8
73+
74+
75+
Write-Host "Prepare dataset"
76+
# change topk for test
77+
$src_topk='"topk": 5'
78+
$dst_topk='"topk": 1000'
79+
$src_pipeline_file="$work_dir\pipeline.json"
80+
$tmp_pipeline_file="$work_dir\pipeline_tmp.json"
81+
Move-Item $src_pipeline_file $tmp_pipeline_file -force
82+
(Get-Content -Path $tmp_pipeline_file) -replace $src_topk, $dst_topk | Add-Content -Path $src_pipeline_file
83+
84+
Write-Host "test sdk model"
85+
86+
python tools\test.py `
87+
$sdk_cfg `
88+
$model_cfg `
89+
--model $work_dir `
90+
--device $device `
91+
--log2file $work_dir\test_sdk.log `
92+
--speed-test `
93+
--log-interval 50 `
94+
--warmup 20 `
95+
--batch-size 8`
96+
97+
# test profiler
98+
Write-Host "Profile sdk model"
99+
python tools\profiler.py `
100+
$sdk_cfg `
101+
$model_cfg `
102+
.\data `
103+
--model $work_dir `
104+
--device $device `
105+
--batch-size 8 `
106+
--shape 224x224
107+
108+
# remove temp data
109+
Remove-Item -Path "$work_dir" -Force -Recurse
110+
Write-Host "All done"

.github/scripts/test_mmcls_full_pipeline.sh

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/backend-ort.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
export MMDEPLOY_DIR=$(pwd)
4444
export ONNXRUNTIME_DIR=$MMDEPLOY_DIR/../mmdeploy-dep/onnxruntime-linux-x64-1.8.1
4545
export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$MMDEPLOY_DIR/build/install/lib:$LD_LIBRARY_PATH
46-
bash .github/scripts/test_mmcls_full_pipeline.sh
46+
bash .circleci/scripts/linux/test_full_pipeline.sh ort cpu

0 commit comments

Comments
 (0)