Skip to content

Commit eebe199

Browse files
authored
Build wheels for rknn linux aarch64 (#1928)
1 parent 82cb8a5 commit eebe199

File tree

4 files changed

+131
-4
lines changed

4 files changed

+131
-4
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: build-wheels-aarch64-rknn
2+
3+
on:
4+
push:
5+
branches:
6+
- wheel
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: build-wheels-aarch64-rknn-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build_wheels_aarch64_rknn:
15+
runs-on: ${{ matrix.os }}
16+
name: ${{ matrix.os }} ${{ matrix.python-version }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-22.04-arm]
21+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install Python dependencies
34+
shell: bash
35+
run: |
36+
python3 -m pip install --upgrade pip numpy pypinyin sentencepiece setuptools wheel
37+
38+
- name: ccache
39+
uses: hendrikmuhs/[email protected]
40+
with:
41+
key: ${{ matrix.os }}-rknn-linux-aarch64-wheel
42+
43+
- name: Download rknn-toolkit2
44+
shell: bash
45+
run: |
46+
git clone --depth 1 https://github.com/airockchip/rknn-toolkit2
47+
48+
- name: Build sherpa-onnx
49+
shell: bash
50+
run: |
51+
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
52+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
53+
cmake --version
54+
55+
echo "config: ${{ matrix.config }}"
56+
uname -a
57+
which gcc
58+
59+
gcc --version
60+
g++ --version
61+
62+
echo "pwd"
63+
64+
ls -lh
65+
66+
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
67+
pushd alsa-lib
68+
./gitcompile
69+
popd
70+
71+
export SHERPA_ONNX_RKNN_TOOLKIT2_PATH=$PWD/rknn-toolkit2
72+
export SHERPA_ONNX_RKNN_TOOLKIT2_LIB_DIR=$SHERPA_ONNX_RKNN_TOOLKIT2_PATH/rknpu2/runtime/Linux/librknn_api/aarch64
73+
export CPLUS_INCLUDE_PATH=$SHERPA_ONNX_RKNN_TOOLKIT2_PATH/rknpu2/runtime/Linux/librknn_api/include:$CPLUS_INCLUDE_PATH
74+
export CPLUS_INCLUDE_PATH=$PWD/alsa-lib/include:$CPLUS_INCLUDE_PATH
75+
export SHERPA_ONNX_ALSA_LIB_DIR=$PWD/alsa-lib/src/.libs
76+
77+
export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_RKNN=ON -DSHERPA_ONNX_ENABLE_ALSA=1"
78+
python3 setup.py bdist_wheel
79+
80+
81+
- name: Display results
82+
shell: bash
83+
run: |
84+
ls -lh dist
85+
86+
- name: Publish to huggingface
87+
env:
88+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
89+
uses: nick-fields/retry@v3
90+
with:
91+
max_attempts: 20
92+
timeout_seconds: 200
93+
shell: bash
94+
command: |
95+
git config --global user.email "[email protected]"
96+
git config --global user.name "Fangjun Kuang"
97+
98+
rm -rf huggingface
99+
export GIT_LFS_SKIP_SMUDGE=1
100+
export GIT_CLONE_PROTECTION_ACTIVE=false
101+
102+
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
103+
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
104+
105+
d=rknn/$SHERPA_ONNX_VERSION/
106+
107+
git clone https://csukuangfj:[email protected]/csukuangfj/sherpa-onnx-wheels huggingface
108+
cd huggingface
109+
git fetch
110+
git pull
111+
git merge -m "merge remote" --ff origin main
112+
113+
mkdir -p $d
114+
115+
cp -v ../dist/*.whl $d/
116+
117+
git status
118+
git add .
119+
git commit -m "add more wheels"
120+
git push https://csukuangfj:[email protected]/csukuangfj/sherpa-onnx-wheels main
121+
122+
- uses: actions/upload-artifact@v4
123+
with:
124+
name: wheel-${{ matrix.python-version }}
125+
path: ./dist/*.whl

.github/workflows/linux.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ jobs:
174174
175175
cp -a build/install/bin $dst/
176176
if [[ ${{ matrix.shared_lib }} == ON ]]; then
177-
cp -av build/install/lib $dst/
177+
mkdir $dst/lib
178+
cp -av build/install/lib/*.so* $dst/lib/
178179
fi
179180
cp -a build/install/include $dst/
180181

.github/workflows/rknn-linux-aarch64.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ jobs:
152152
cp -a build/install/bin $dst/
153153
154154
if [[ ${{ matrix.shared }} == ON ]]; then
155-
cp -v build/install/lib/lib*.so $dst/
155+
mkdir -p $dst/lib
156+
cp -v build/install/lib/lib*.so $dst/lib/
156157
fi
157158
158159
ls -lh build/install/lib
@@ -218,7 +219,7 @@ jobs:
218219
file: sherpa-onnx-*linux-aarch64*.tar.bz2
219220

220221
- name: Release pre-compiled binaries and libs for rknn linux aarch64
221-
# if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
222+
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
222223
uses: svenstaro/upload-release-action@v2
223224
with:
224225
file_glob: true

sherpa-onnx/csrc/online-model-config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool OnlineModelConfig::Validate() const {
8484
EndsWith(transducer.joiner, ".onnx"))) {
8585
SHERPA_ONNX_LOGE(
8686
"--provider is rknn, but you pass onnx model "
87-
"filenames. encoder: '%s', decoder: '%s', joiner: %'s'",
87+
"filenames. encoder: '%s', decoder: '%s', joiner: '%s'",
8888
transducer.encoder.c_str(), transducer.decoder.c_str(),
8989
transducer.joiner.c_str());
9090
return false;

0 commit comments

Comments
 (0)