Skip to content

Commit aa66810

Browse files
authored
Provide pre-compiled shepra-onnx libs/binaries for CUDA 12.x + onnxruntime 1.22.0 (k2-fsa#2599)
1 parent bff2691 commit aa66810

4 files changed

Lines changed: 111 additions & 39 deletions

File tree

.github/workflows/linux-gpu.yaml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ concurrency:
2828
jobs:
2929
linux_gpu:
3030
runs-on: ${{ matrix.os }}
31-
name: ${{ matrix.build_type }}
31+
name: ${{ matrix.build_type }} ${{ matrix.onnxruntime_version }}
3232
strategy:
3333
fail-fast: false
3434
matrix:
3535
os: [ubuntu-latest]
3636
# build_type: [Release, Debug]
3737
build_type: [Release]
38+
onnxruntime_version: ["1.17.1", "1.22.0"]
3839

3940
steps:
4041
- uses: actions/checkout@v4
@@ -64,6 +65,17 @@ jobs:
6465
6566
cd /home/runner/work/sherpa-onnx/sherpa-onnx
6667
68+
onnxruntime_version=${{ matrix.onnxruntime_version }}
69+
if [[ $onnxruntime_version == "1.22.0" ]]; then
70+
curl -SL -O https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.22.0/onnxruntime-linux-x64-gpu-1.22.0-patched.zip
71+
unzip onnxruntime-linux-x64-gpu-1.22.0-patched.zip
72+
73+
export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/onnxruntime-linux-x64-gpu-1.22.0-patched/lib
74+
export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/onnxruntime-linux-x64-gpu-1.22.0-patched/include
75+
76+
ls -lh /home/runner/work/sherpa-onnx/sherpa-onnx/onnxruntime-linux-x64-gpu-1.22.0-patched/lib/libonnxruntime.so
77+
fi
78+
6779
git clone --depth 1 --branch v1.2.12 https://github.com/alsa-project/alsa-lib
6880
pushd alsa-lib
6981
./gitcompile
@@ -88,6 +100,11 @@ jobs:
88100
ls -lh lib
89101
ls -lh bin
90102
103+
if [[ $onnxruntime_version == "1.22.0" ]]; then
104+
cp -v $SHERPA_ONNXRUNTIME_LIB_DIR/libonnxruntime* ./lib/
105+
cp -v $SHERPA_ONNXRUNTIME_LIB_DIR/libonnxruntime* install/lib/
106+
fi
107+
91108
echo "----"
92109
ls -lh install/lib
93110
@@ -100,7 +117,7 @@ jobs:
100117
du -h -d1 .
101118
sudo chown -R $USER ./build
102119
ls -lh build/bin
103-
ls -lh build/_deps/onnxruntime-src/lib/
120+
ls -lh build/_deps/onnxruntime-src/lib/ || true
104121
105122
echo "strip"
106123
strip build/bin/*
@@ -120,12 +137,17 @@ jobs:
120137
strings build/install/lib/*.so | grep "^GLIBC_"
121138
122139
- name: Copy files
123-
if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
124140
shell: bash
125141
run: |
126142
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
127143
128144
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-x64-gpu
145+
146+
onnxruntime_version=${{ matrix.onnxruntime_version }}
147+
if [[ $onnxruntime_version == "1.22.0" ]]; then
148+
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-cuda-12.x-cudnn-9.x-linux-x64-gpu
149+
fi
150+
129151
mkdir $dst
130152
131153
cp -a build/install/bin $dst/
@@ -137,15 +159,23 @@ jobs:
137159
tar cjvf ${dst}.tar.bz2 $dst
138160
139161
- name: Release pre-compiled binaries and libs for linux x64
140-
if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
162+
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
163+
uses: svenstaro/upload-release-action@v2
164+
with:
165+
file_glob: true
166+
overwrite: true
167+
file: sherpa-onnx-*gpu.tar.bz2
168+
repo_name: k2-fsa/sherpa-onnx
169+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
170+
tag: v1.12.13
171+
172+
- name: Release pre-compiled binaries and libs for linux x64
173+
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
141174
uses: svenstaro/upload-release-action@v2
142175
with:
143176
file_glob: true
144177
overwrite: true
145-
file: sherpa-onnx-*linux-x64-gpu.tar.bz2
146-
# repo_name: k2-fsa/sherpa-onnx
147-
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
148-
# tag: v1.11.3
178+
file: sherpa-onnx-*gpu.tar.bz2
149179

150180
- name: Display dependencies of sherpa-onnx for linux
151181
shell: bash

.github/workflows/windows-x64-cuda.yaml

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ concurrency:
2525

2626
jobs:
2727
windows_x64_cuda:
28-
name: Windows x64 CUDA
28+
name: Windows x64 CUDA ${{ matrix.onnxruntime_version }}
2929
runs-on: ${{ matrix.os }}
3030
strategy:
3131
fail-fast: false
3232
matrix:
3333
os: [windows-latest]
34+
onnxruntime_version: ["1.17.1", "1.22.0"]
3435

3536
steps:
3637
- uses: actions/checkout@v4
@@ -46,6 +47,15 @@ jobs:
4647
- name: Configure CMake
4748
shell: bash
4849
run: |
50+
onnxruntime_version=${{ matrix.onnxruntime_version }}
51+
if [[ $onnxruntime_version == "1.22.0" ]]; then
52+
curl -SL -O https://github.com/microsoft/onnxruntime/releases/download/v1.22.0/onnxruntime-win-x64-gpu-1.22.0.zip
53+
unzip onnxruntime-win-x64-gpu-1.22.0.zip
54+
55+
export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/onnxruntime-win-x64-gpu-1.22.0/lib
56+
export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/onnxruntime-win-x64-gpu-1.22.0/include
57+
fi
58+
4959
mkdir build
5060
cd build
5161
cmake \
@@ -65,6 +75,51 @@ jobs:
6575
6676
ls -lh ./bin/Release/sherpa-onnx.exe
6777
78+
onnxruntime_version=${{ matrix.onnxruntime_version }}
79+
if [[ $onnxruntime_version == "1.22.0" ]]; then
80+
cp -v ../onnxruntime-win-x64-gpu-1.22.0/lib/*.dll ./bin/Release/
81+
cp -v ../onnxruntime-win-x64-gpu-1.22.0/lib/*.dll ./install/bin/
82+
fi
83+
84+
- name: Copy files
85+
shell: bash
86+
run: |
87+
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
88+
89+
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x64-cuda
90+
91+
onnxruntime_version=${{ matrix.onnxruntime_version }}
92+
if [[ $onnxruntime_version == "1.22.0" ]]; then
93+
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-cuda-12.x-cudnn-9.x-win-x64-cuda
94+
fi
95+
96+
mkdir $dst
97+
98+
cp -a build/install/bin $dst/
99+
cp -a build/install/lib $dst/
100+
cp -a build/install/include $dst/
101+
102+
tar cjvf ${dst}.tar.bz2 $dst
103+
104+
- name: Release pre-compiled binaries and libs for linux x64
105+
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
106+
uses: svenstaro/upload-release-action@v2
107+
with:
108+
file_glob: true
109+
overwrite: true
110+
file: sherpa-onnx-*cuda.tar.bz2
111+
repo_name: k2-fsa/sherpa-onnx
112+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
113+
tag: v1.12.13
114+
115+
- name: Release pre-compiled binaries and libs for linux x64
116+
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
117+
uses: svenstaro/upload-release-action@v2
118+
with:
119+
file_glob: true
120+
overwrite: true
121+
file: sherpa-onnx-*cuda.tar.bz2
122+
68123
- name: Test spoken language identification
69124
shell: bash
70125
run: |
@@ -137,24 +192,4 @@ jobs:
137192
138193
.github/scripts/test-online-transducer.sh
139194
140-
- name: Copy files
141-
shell: bash
142-
run: |
143-
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
144195
145-
dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x64-cuda
146-
mkdir $dst
147-
148-
cp -a build/install/bin $dst/
149-
cp -a build/install/lib $dst/
150-
cp -a build/install/include $dst/
151-
152-
tar cjvf ${dst}.tar.bz2 $dst
153-
154-
- name: Release pre-compiled binaries and libs for Windows x64 CUDA
155-
if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
156-
uses: svenstaro/upload-release-action@v2
157-
with:
158-
file_glob: true
159-
overwrite: true
160-
file: sherpa-onnx-*-win-x64-cuda.tar.bz2

cmake/onnxruntime.cmake

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,36 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE)
153153
if(APPLE)
154154
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.dylib)
155155
elseif(WIN32)
156-
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.lib)
157-
if(SHERPA_ONNX_ENABLE_DIRECTML)
158-
include(onnxruntime-win-x64-directml)
156+
if(SHERPA_ONNX_ENABLE_GPU)
157+
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.dll)
158+
else()
159+
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.lib)
160+
if(SHERPA_ONNX_ENABLE_DIRECTML)
161+
include(onnxruntime-win-x64-directml)
162+
endif()
159163
endif()
160164
else()
161165
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.so)
162166
endif()
167+
163168
if(NOT EXISTS ${location_onnxruntime_lib})
169+
message(STATUS "${location_onnxruntime_lib} does not exist. Try static lib")
170+
164171
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
165172
if(NOT EXISTS ${location_onnxruntime_lib})
166173
message(FATAL_ERROR "${location_onnxruntime_lib} cannot be found")
167174
endif()
168175
set(onnxruntime_lib_files $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
169176
message("Use static lib: ${onnxruntime_lib_files}")
170177
endif()
178+
171179
if(SHERPA_ONNX_ENABLE_GPU)
172-
set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so)
180+
if(WIN32)
181+
set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime_providers_cuda.dll)
182+
else()
183+
set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.so)
184+
endif()
185+
173186
if(NOT EXISTS ${location_onnxruntime_cuda_lib})
174187
set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.a)
175188
endif()

sherpa-onnx/csrc/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ if(DEFINED OHOS AND x${OHOS} STREQUAL xOHOS)
283283
)
284284
endif()
285285

286-
if(SHERPA_ONNX_ENABLE_GPU)
287-
target_link_libraries(sherpa-onnx-core
288-
onnxruntime_providers_shared
289-
)
290-
endif()
291-
292286
if(SHERPA_ONNX_ENABLE_RKNN)
293287
if(DEFINED ENV{SHERPA_ONNX_RKNN_TOOLKIT2_LIB_DIR})
294288
target_link_libraries(sherpa-onnx-core -L$ENV{SHERPA_ONNX_RKNN_TOOLKIT2_LIB_DIR} -lrknnrt)

0 commit comments

Comments
 (0)