Fangjun Kuang
Committed by GitHub

Provide pre-compiled whls for cuda 12.x on Linux x64 and Windows x64 (#2601)

@@ -15,13 +15,14 @@ concurrency: @@ -15,13 +15,14 @@ concurrency:
15 15
16 jobs: 16 jobs:
17 build_wheels_linux_cuda: 17 build_wheels_linux_cuda:
18 - name: ${{ matrix.manylinux }} ${{ matrix.python-version }} 18 + name: ${{ matrix.manylinux }} ${{ matrix.python-version }} ${{ matrix.onnxruntime_version }}
19 runs-on: ${{ matrix.os }} 19 runs-on: ${{ matrix.os }}
20 strategy: 20 strategy:
21 fail-fast: false 21 fail-fast: false
22 matrix: 22 matrix:
23 os: [ubuntu-22.04] 23 os: [ubuntu-22.04]
24 python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] 24 python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
  25 + onnxruntime_version: ["1.17.1", "1.22.0"]
25 26
26 steps: 27 steps:
27 - uses: actions/checkout@v4 28 - uses: actions/checkout@v4
@@ -69,6 +70,16 @@ jobs: @@ -69,6 +70,16 @@ jobs:
69 export SHERPA_ONNX_ENABLE_ALSA=1 70 export SHERPA_ONNX_ENABLE_ALSA=1
70 export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_GPU=ON" 71 export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_GPU=ON"
71 72
  73 + onnxruntime_version=${{ matrix.onnxruntime_version }}
  74 + if [[ $onnxruntime_version == "1.22.0" ]]; then
  75 + curl -SL -O https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.22.0/onnxruntime-linux-x64-gpu-1.22.0-patched.zip
  76 + unzip onnxruntime-linux-x64-gpu-1.22.0-patched.zip
  77 +
  78 + export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/onnxruntime-linux-x64-gpu-1.22.0-patched/lib
  79 + export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/onnxruntime-linux-x64-gpu-1.22.0-patched/include
  80 + export SHERPA_ONNX_CUDA_VERSION="12.cudnn9"
  81 + fi
  82 +
72 python3 setup.py bdist_wheel 83 python3 setup.py bdist_wheel
73 84
74 ls -lh dist 85 ls -lh dist
@@ -80,6 +91,8 @@ jobs: @@ -80,6 +91,8 @@ jobs:
80 run: | 91 run: |
81 ls -lh ./wheelhouse/ 92 ls -lh ./wheelhouse/
82 93
  94 + unzip -l ./wheelhouse/*.whl
  95 +
83 - name: Install patchelf 96 - name: Install patchelf
84 shell: bash 97 shell: bash
85 run: | 98 run: |
@@ -97,9 +110,10 @@ jobs: @@ -97,9 +110,10 @@ jobs:
97 rm -rf ./wheelhouse 110 rm -rf ./wheelhouse
98 mv ./wheels ./wheelhouse 111 mv ./wheels ./wheelhouse
99 112
  113 +
100 - uses: actions/upload-artifact@v4 114 - uses: actions/upload-artifact@v4
101 with: 115 with:
102 - name: wheel-cuda-${{ matrix.python-version }} 116 + name: wheel-cuda-${{ matrix.python-version }}-${{ matrix.onnxruntime_version }}
103 path: ./wheelhouse/*.whl 117 path: ./wheelhouse/*.whl
104 118
105 - name: Publish to huggingface 119 - name: Publish to huggingface
@@ -15,13 +15,14 @@ concurrency: @@ -15,13 +15,14 @@ concurrency:
15 15
16 jobs: 16 jobs:
17 build_wheels_win64_cuda: 17 build_wheels_win64_cuda:
18 - name: ${{ matrix.python-version }} 18 + name: ${{ matrix.python-version }} ${{ matrix.onnxruntime_version }}
19 runs-on: ${{ matrix.os }} 19 runs-on: ${{ matrix.os }}
20 strategy: 20 strategy:
21 fail-fast: false 21 fail-fast: false
22 matrix: 22 matrix:
23 os: [windows-2022] 23 os: [windows-2022]
24 python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] 24 python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
  25 + onnxruntime_version: ["1.17.1", "1.22.0"]
25 26
26 steps: 27 steps:
27 - uses: actions/checkout@v4 28 - uses: actions/checkout@v4
@@ -44,6 +45,17 @@ jobs: @@ -44,6 +45,17 @@ jobs:
44 45
45 export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_GPU=ON" 46 export SHERPA_ONNX_CMAKE_ARGS="-DSHERPA_ONNX_ENABLE_GPU=ON"
46 47
  48 + onnxruntime_version=${{ matrix.onnxruntime_version }}
  49 + if [[ $onnxruntime_version == "1.22.0" ]]; then
  50 + curl -SL -O https://github.com/microsoft/onnxruntime/releases/download/v1.22.0/onnxruntime-win-x64-gpu-1.22.0.zip
  51 + unzip onnxruntime-win-x64-gpu-1.22.0.zip
  52 +
  53 + export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/onnxruntime-win-x64-gpu-1.22.0/lib
  54 + export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/onnxruntime-win-x64-gpu-1.22.0/include
  55 +
  56 + export SHERPA_ONNX_CUDA_VERSION="12.cudnn9"
  57 + fi
  58 +
47 python3 setup.py bdist_wheel 59 python3 setup.py bdist_wheel
48 60
49 ls -lh ./dist/ 61 ls -lh ./dist/
@@ -54,10 +66,11 @@ jobs: @@ -54,10 +66,11 @@ jobs:
54 shell: bash 66 shell: bash
55 run: | 67 run: |
56 ls -lh ./wheelhouse/ 68 ls -lh ./wheelhouse/
  69 + unzip -l ./wheelhouse/*.whl
57 70
58 - uses: actions/upload-artifact@v4 71 - uses: actions/upload-artifact@v4
59 with: 72 with:
60 - name: wheel-${{ matrix.python-version }} 73 + name: wheel-${{ matrix.python-version }}-${{ matrix.onnxruntime_version }}
61 path: ./wheelhouse/*.whl 74 path: ./wheelhouse/*.whl
62 75
63 - name: Publish to huggingface 76 - name: Publish to huggingface
@@ -100,11 +100,6 @@ jobs: @@ -100,11 +100,6 @@ jobs:
100 ls -lh lib 100 ls -lh lib
101 ls -lh bin 101 ls -lh bin
102 102
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 -  
108 echo "----" 103 echo "----"
109 ls -lh install/lib 104 ls -lh install/lib
110 105
@@ -76,10 +76,6 @@ jobs: @@ -76,10 +76,6 @@ jobs:
76 ls -lh ./bin/Release/sherpa-onnx.exe 76 ls -lh ./bin/Release/sherpa-onnx.exe
77 77
78 onnxruntime_version=${{ matrix.onnxruntime_version }} 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 79
84 - name: Copy files 80 - name: Copy files
85 shell: bash 81 shell: bash
@@ -9,6 +9,7 @@ import shutil @@ -9,6 +9,7 @@ import shutil
9 import sys 9 import sys
10 from pathlib import Path 10 from pathlib import Path
11 11
  12 +import glob
12 import setuptools 13 import setuptools
13 from setuptools.command.build_ext import build_ext 14 from setuptools.command.build_ext import build_ext
14 15
@@ -251,8 +252,6 @@ class BuildExtension(build_ext): @@ -251,8 +252,6 @@ class BuildExtension(build_ext):
251 os.system(f"mkdir {dst}") 252 os.system(f"mkdir {dst}")
252 os.system(f"dir {dst}") 253 os.system(f"dir {dst}")
253 254
254 - import glob  
255 -  
256 ext = "pyd" if sys.platform.startswith("win") else "so" 255 ext = "pyd" if sys.platform.startswith("win") else "so"
257 pattern = os.path.join(self.build_temp, "**", f"_sherpa_onnx.*.{ext}") 256 pattern = os.path.join(self.build_temp, "**", f"_sherpa_onnx.*.{ext}")
258 matches = glob.glob(pattern, recursive=True) 257 matches = glob.glob(pattern, recursive=True)
@@ -117,30 +117,6 @@ set_target_properties(onnxruntime PROPERTIES @@ -117,30 +117,6 @@ set_target_properties(onnxruntime PROPERTIES
117 INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include" 117 INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
118 ) 118 )
119 119
120 -find_library(location_onnxruntime_cuda_lib onnxruntime_providers_cuda  
121 - PATHS  
122 - "${onnxruntime_SOURCE_DIR}/lib"  
123 - NO_CMAKE_SYSTEM_PATH  
124 -)  
125 -  
126 -add_library(onnxruntime_providers_cuda SHARED IMPORTED)  
127 -set_target_properties(onnxruntime_providers_cuda PROPERTIES  
128 - IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}  
129 -)  
130 -message(STATUS "location_onnxruntime_cuda_lib: ${location_onnxruntime_cuda_lib}")  
131 -  
132 -# for libonnxruntime_providers_shared.so  
133 -find_library(location_onnxruntime_providers_shared_lib onnxruntime_providers_shared  
134 - PATHS  
135 - "${onnxruntime_SOURCE_DIR}/lib"  
136 - NO_CMAKE_SYSTEM_PATH  
137 -)  
138 -add_library(onnxruntime_providers_shared SHARED IMPORTED)  
139 -set_target_properties(onnxruntime_providers_shared PROPERTIES  
140 - IMPORTED_LOCATION ${location_onnxruntime_providers_shared_lib}  
141 -)  
142 -message(STATUS "location_onnxruntime_providers_shared_lib: ${location_onnxruntime_providers_shared_lib}")  
143 -  
144 file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*") 120 file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
145 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 121 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
146 install(FILES ${onnxruntime_lib_files} DESTINATION lib) 122 install(FILES ${onnxruntime_lib_files} DESTINATION lib)
@@ -73,30 +73,6 @@ set_target_properties(onnxruntime PROPERTIES @@ -73,30 +73,6 @@ set_target_properties(onnxruntime PROPERTIES
73 INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include" 73 INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"
74 ) 74 )
75 75
76 -find_library(location_onnxruntime_cuda_lib onnxruntime_providers_cuda  
77 - PATHS  
78 - "${onnxruntime_SOURCE_DIR}/lib"  
79 - NO_CMAKE_SYSTEM_PATH  
80 -)  
81 -  
82 -add_library(onnxruntime_providers_cuda SHARED IMPORTED)  
83 -set_target_properties(onnxruntime_providers_cuda PROPERTIES  
84 - IMPORTED_LOCATION ${location_onnxruntime_cuda_lib}  
85 -)  
86 -message(STATUS "location_onnxruntime_cuda_lib: ${location_onnxruntime_cuda_lib}")  
87 -  
88 -# for libonnxruntime_providers_shared.so  
89 -find_library(location_onnxruntime_providers_shared_lib onnxruntime_providers_shared  
90 - PATHS  
91 - "${onnxruntime_SOURCE_DIR}/lib"  
92 - NO_CMAKE_SYSTEM_PATH  
93 -)  
94 -add_library(onnxruntime_providers_shared SHARED IMPORTED)  
95 -set_target_properties(onnxruntime_providers_shared PROPERTIES  
96 - IMPORTED_LOCATION ${location_onnxruntime_providers_shared_lib}  
97 -)  
98 -message(STATUS "location_onnxruntime_providers_shared_lib: ${location_onnxruntime_providers_shared_lib}")  
99 -  
100 file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*") 76 file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*")
101 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 77 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
102 install(FILES ${onnxruntime_lib_files} DESTINATION lib) 78 install(FILES ${onnxruntime_lib_files} DESTINATION lib)
@@ -82,52 +82,6 @@ file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll @@ -82,52 +82,6 @@ file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll
82 ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE} 82 ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}
83 ) 83 )
84 84
85 -# for onnxruntime_providers_cuda.dll  
86 -  
87 -find_library(location_onnxruntime_providers_cuda_lib onnxruntime_providers_cuda  
88 - PATHS  
89 - "${onnxruntime_SOURCE_DIR}/lib"  
90 - NO_CMAKE_SYSTEM_PATH  
91 -)  
92 -message(STATUS "location_onnxruntime_providers_cuda_lib: ${location_onnxruntime_providers_cuda_lib}")  
93 -  
94 -add_library(onnxruntime_providers_cuda SHARED IMPORTED)  
95 -set_target_properties(onnxruntime_providers_cuda PROPERTIES  
96 - IMPORTED_LOCATION ${location_onnxruntime_providers_cuda_lib}  
97 - INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"  
98 -)  
99 -  
100 -set_property(TARGET onnxruntime_providers_cuda  
101 - PROPERTY  
102 - IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.lib"  
103 -)  
104 -  
105 -# for onnxruntime_providers_shared.dll  
106 -  
107 -find_library(location_onnxruntime_providers_shared_lib onnxruntime_providers_shared  
108 - PATHS  
109 - "${onnxruntime_SOURCE_DIR}/lib"  
110 - NO_CMAKE_SYSTEM_PATH  
111 -)  
112 -message(STATUS "location_onnxruntime_providers_shared_lib: ${location_onnxruntime_providers_shared_lib}")  
113 -add_library(onnxruntime_providers_shared SHARED IMPORTED)  
114 -set_target_properties(onnxruntime_providers_shared PROPERTIES  
115 - IMPORTED_LOCATION ${location_onnxruntime_providers_shared_lib}  
116 - INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include"  
117 -)  
118 -set_property(TARGET onnxruntime_providers_shared  
119 - PROPERTY  
120 - IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_shared.lib"  
121 -)  
122 -  
123 -file(  
124 - COPY  
125 - ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.dll  
126 - ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_shared.dll  
127 - DESTINATION  
128 - ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}  
129 -)  
130 -  
131 file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll") 85 file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/*.dll")
132 86
133 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") 87 message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
@@ -155,6 +155,7 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE) @@ -155,6 +155,7 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE)
155 elseif(WIN32) 155 elseif(WIN32)
156 if(SHERPA_ONNX_ENABLE_GPU) 156 if(SHERPA_ONNX_ENABLE_GPU)
157 set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.dll) 157 set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.dll)
  158 + set(location_onnxruntime_lib2 $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.lib)
158 else() 159 else()
159 set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.lib) 160 set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/onnxruntime.lib)
160 if(SHERPA_ONNX_ENABLE_DIRECTML) 161 if(SHERPA_ONNX_ENABLE_DIRECTML)
@@ -175,18 +176,6 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE) @@ -175,18 +176,6 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE)
175 set(onnxruntime_lib_files $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a) 176 set(onnxruntime_lib_files $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
176 message("Use static lib: ${onnxruntime_lib_files}") 177 message("Use static lib: ${onnxruntime_lib_files}")
177 endif() 178 endif()
178 -  
179 - if(SHERPA_ONNX_ENABLE_GPU)  
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 -  
186 - if(NOT EXISTS ${location_onnxruntime_cuda_lib})  
187 - set(location_onnxruntime_cuda_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime_providers_cuda.a)  
188 - endif()  
189 - endif()  
190 else() 179 else()
191 find_library(location_onnxruntime_lib onnxruntime 180 find_library(location_onnxruntime_lib onnxruntime
192 PATHS 181 PATHS
@@ -194,37 +183,41 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE) @@ -194,37 +183,41 @@ if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE)
194 /usr/lib 183 /usr/lib
195 /usr/local/lib 184 /usr/local/lib
196 ) 185 )
197 -  
198 - if(SHERPA_ONNX_ENABLE_GPU)  
199 - find_library(location_onnxruntime_cuda_lib onnxruntime_providers_cuda  
200 - PATHS  
201 - /lib  
202 - /usr/lib  
203 - /usr/local/lib  
204 - )  
205 - endif()  
206 endif() 186 endif()
207 187
208 message(STATUS "location_onnxruntime_lib: ${location_onnxruntime_lib}") 188 message(STATUS "location_onnxruntime_lib: ${location_onnxruntime_lib}")
209 - if(SHERPA_ONNX_ENABLE_GPU)  
210 - message(STATUS "location_onnxruntime_cuda_lib: ${location_onnxruntime_cuda_lib}")  
211 - endif()  
212 endif() 189 endif()
213 190
214 if(location_onnxruntime_header_dir AND location_onnxruntime_lib) 191 if(location_onnxruntime_header_dir AND location_onnxruntime_lib)
215 if(NOT DEFINED onnxruntime_lib_files) 192 if(NOT DEFINED onnxruntime_lib_files)
216 add_library(onnxruntime SHARED IMPORTED) 193 add_library(onnxruntime SHARED IMPORTED)
217 - set_target_properties(onnxruntime PROPERTIES  
218 - IMPORTED_LOCATION ${location_onnxruntime_lib}  
219 - IMPORTED_IMPLIB ${location_onnxruntime_lib}  
220 - INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}"  
221 - )  
222 - if(SHERPA_ONNX_ENABLE_GPU AND location_onnxruntime_cuda_lib)  
223 - add_library(onnxruntime_providers_cuda SHARED IMPORTED)  
224 - set_target_properties(onnxruntime_providers_cuda PROPERTIES  
225 - IMPORTED_LOCATION ${location_onnxruntime_cuda_lib} 194 +
  195 + if(WIN32)
  196 + set_target_properties(onnxruntime PROPERTIES
  197 + IMPORTED_LOCATION ${location_onnxruntime_lib}
  198 + IMPORTED_IMPLIB ${location_onnxruntime_lib2}
  199 + INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}"
  200 + )
  201 + else()
  202 + set_target_properties(onnxruntime PROPERTIES
  203 + IMPORTED_LOCATION ${location_onnxruntime_lib}
  204 + INTERFACE_INCLUDE_DIRECTORIES "${location_onnxruntime_header_dir}"
226 ) 205 )
227 endif() 206 endif()
  207 +
  208 + if(WIN32)
  209 + file(GLOB onnxruntime_lib_files "$ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/*.dll")
  210 + else()
  211 + file(GLOB onnxruntime_lib_files "$ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime*")
  212 + endif()
  213 +
  214 + message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
  215 +
  216 + install(FILES ${onnxruntime_lib_files} DESTINATION lib)
  217 +
  218 + if(WIN32)
  219 + install(FILES ${onnxruntime_lib_files} DESTINATION bin)
  220 + endif()
228 endif() 221 endif()
229 else() 222 else()
230 if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE) 223 if(SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE)
@@ -34,6 +34,10 @@ def get_package_version(): @@ -34,6 +34,10 @@ def get_package_version():
34 if "-DSHERPA_ONNX_ENABLE_GPU=ON" in cmake_args: 34 if "-DSHERPA_ONNX_ENABLE_GPU=ON" in cmake_args:
35 extra_version = "+cuda" 35 extra_version = "+cuda"
36 36
  37 + cuda_version = os.environ.get("SHERPA_ONNX_CUDA_VERSION", "")
  38 + if cuda_version:
  39 + extra_version += cuda_version
  40 +
37 latest_version += extra_version 41 latest_version += extra_version
38 42
39 return latest_version 43 return latest_version
@@ -291,7 +291,7 @@ if(SHERPA_ONNX_ENABLE_RKNN) @@ -291,7 +291,7 @@ if(SHERPA_ONNX_ENABLE_RKNN)
291 endif() 291 endif()
292 endif() 292 endif()
293 293
294 -if((BUILD_SHARED_LIBS OR SHERPA_ONNX_USE_PRE_INSTALLED_ONNXRUNTIME_IF_AVAILABLE) AND NOT DEFINED onnxruntime_lib_files) 294 +if(TARGET onnxruntime)
295 target_link_libraries(sherpa-onnx-core onnxruntime) 295 target_link_libraries(sherpa-onnx-core onnxruntime)
296 else() 296 else()
297 target_link_libraries(sherpa-onnx-core ${onnxruntime_lib_files}) 297 target_link_libraries(sherpa-onnx-core ${onnxruntime_lib_files})