diff --git a/.github/workflows/linux-gpu.yaml b/.github/workflows/linux-gpu.yaml new file mode 100644 index 00000000..7b14ac2b --- /dev/null +++ b/.github/workflows/linux-gpu.yaml @@ -0,0 +1,151 @@ +name: linux-gpu + +on: + push: + branches: + - master + tags: + - '*' + paths: + - '.github/workflows/linux-gpu.yaml' + - '.github/scripts/test-online-transducer.sh' + - '.github/scripts/test-offline-transducer.sh' + - '.github/scripts/test-offline-ctc.sh' + - 'CMakeLists.txt' + - 'cmake/**' + - 'sherpa-onnx/csrc/*' + - 'sherpa-onnx/c-api/*' + - 'c-api-examples/**' + pull_request: + branches: + - master + paths: + - '.github/workflows/linux-gpu.yaml' + - '.github/scripts/test-online-transducer.sh' + - '.github/scripts/test-offline-transducer.sh' + - '.github/scripts/test-offline-ctc.sh' + - 'CMakeLists.txt' + - 'cmake/**' + - 'sherpa-onnx/csrc/*' + - 'sherpa-onnx/c-api/*' + release: + types: + - published + + workflow_dispatch: + inputs: + release: + description: "Whether to release" + type: boolean + +env: + RELEASE: + |- # Release if there is a release tag name or a release flag in workflow_dispatch + ${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }} + +concurrency: + group: linux-gpu-${{ github.ref }} + cancel-in-progress: true + +jobs: + linux_gpu: + runs-on: ${{ matrix.os }} + name: ${{ matrix.build_type }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + build_type: [Release, Debug] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Configure CMake + shell: bash + run: | + mkdir build + cd build + cmake -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_GPU=ON .. + + - name: Build sherpa-onnx for ubuntu + shell: bash + run: | + cd build + make -j2 + make install + + ls -lh lib + ls -lh bin + + - name: Display dependencies of sherpa-onnx for linux + shell: bash + run: | + file build/bin/sherpa-onnx + readelf -d build/bin/sherpa-onnx + + - name: Test offline Whisper + shell: bash + run: | + export PATH=$PWD/build/bin:$PATH + export EXE=sherpa-onnx-offline + + .github/scripts/test-offline-whisper.sh + + - name: Test offline CTC + shell: bash + run: | + export PATH=$PWD/build/bin:$PATH + export EXE=sherpa-onnx-offline + + .github/scripts/test-offline-ctc.sh + + - name: Test offline transducer + shell: bash + run: | + export PATH=$PWD/build/bin:$PATH + export EXE=sherpa-onnx-offline + + .github/scripts/test-offline-transducer.sh + + - name: Test online transducer + shell: bash + run: | + export PATH=$PWD/build/bin:$PATH + export EXE=sherpa-onnx + + .github/scripts/test-online-transducer.sh + + - name: Test online transducer (C API) + shell: bash + run: | + export PATH=$PWD/build/bin:$PATH + export EXE=decode-file-c-api + + .github/scripts/test-online-transducer.sh + + - name: Copy files + if: env.RELEASE == 'true' + shell: bash + run: | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) + + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-linux-x64-gpu + mkdir $dst + + cp -a build/install/bin $dst/ + cp -a build/install/lib $dst/ + cp -a build/install/include $dst/ + + tree $dst + + tar cjvf ${dst}.tar.bz2 $dst + + - name: Release pre-compiled binaries and libs for linux x64 + if: env.RELEASE == 'true' && matrix.build_type == 'Release' + uses: svenstaro/upload-release-action@v2 + with: + file_glob: true + overwrite: true + file: sherpa-onnx-*linux-x64-gpu.tar.bz2 diff --git a/cmake/onnxruntime-linux-x86_64-gpu.cmake b/cmake/onnxruntime-linux-x86_64-gpu.cmake index df6d79cf..9039e287 100644 --- a/cmake/onnxruntime-linux-x86_64-gpu.cmake +++ b/cmake/onnxruntime-linux-x86_64-gpu.cmake @@ -82,6 +82,19 @@ add_library(onnxruntime_providers_cuda SHARED IMPORTED) set_target_properties(onnxruntime_providers_cuda PROPERTIES IMPORTED_LOCATION ${location_onnxruntime_cuda_lib} ) +message(STATUS "location_onnxruntime_cuda_lib: ${location_onnxruntime_cuda_lib}") + +# for libonnxruntime_providers_shared.so +find_library(location_onnxruntime_providers_shared_lib onnxruntime_providers_shared + PATHS + "${onnxruntime_SOURCE_DIR}/lib" + NO_CMAKE_SYSTEM_PATH +) +add_library(onnxruntime_providers_shared SHARED IMPORTED) +set_target_properties(onnxruntime_providers_shared PROPERTIES + IMPORTED_LOCATION ${location_onnxruntime_providers_shared_lib} +) +message(STATUS "location_onnxruntime_providers_shared_lib: ${location_onnxruntime_providers_shared_lib}") file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/libonnxruntime*") message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") diff --git a/cmake/onnxruntime-win-x64-gpu.cmake b/cmake/onnxruntime-win-x64-gpu.cmake index 3155db64..6353222e 100644 --- a/cmake/onnxruntime-win-x64-gpu.cmake +++ b/cmake/onnxruntime-win-x64-gpu.cmake @@ -82,9 +82,18 @@ file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.dll ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE} ) +# for onnxruntime_providers_cuda.dll + +find_library(location_onnxruntime_providers_cuda_lib onnxruntime_providers_cuda + PATHS + "${onnxruntime_SOURCE_DIR}/lib" + NO_CMAKE_SYSTEM_PATH +) +message(STATUS "location_onnxruntime_providers_cuda_lib: ${location_onnxruntime_providers_cuda_lib}") + add_library(onnxruntime_providers_cuda SHARED IMPORTED) set_target_properties(onnxruntime_providers_cuda PROPERTIES - IMPORTED_LOCATION ${location_onnxruntime} + IMPORTED_LOCATION ${location_onnxruntime_providers_cuda_lib} INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include" ) @@ -93,7 +102,28 @@ set_property(TARGET onnxruntime_providers_cuda IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.lib" ) -file(COPY ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.dll +# for onnxruntime_providers_shared.dll + +find_library(location_onnxruntime_providers_shared_lib onnxruntime_providers_shared + PATHS + "${onnxruntime_SOURCE_DIR}/lib" + NO_CMAKE_SYSTEM_PATH +) +message(STATUS "location_onnxruntime_providers_shared_lib: ${location_onnxruntime_providers_shared_lib}") +add_library(onnxruntime_providers_shared SHARED IMPORTED) +set_target_properties(onnxruntime_providers_shared PROPERTIES + IMPORTED_LOCATION ${location_onnxruntime_providers_shared_lib} + INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_SOURCE_DIR}/include" +) +set_property(TARGET onnxruntime_providers_shared + PROPERTY + IMPORTED_IMPLIB "${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_shared.lib" +) + +file( + COPY + ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_cuda.dll + ${onnxruntime_SOURCE_DIR}/lib/onnxruntime_providers_shared.dll DESTINATION ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE} ) diff --git a/sherpa-onnx/csrc/CMakeLists.txt b/sherpa-onnx/csrc/CMakeLists.txt index 9060c0ac..f9befff7 100644 --- a/sherpa-onnx/csrc/CMakeLists.txt +++ b/sherpa-onnx/csrc/CMakeLists.txt @@ -90,6 +90,7 @@ endif() if(SHERPA_ONNX_ENABLE_GPU) target_link_libraries(sherpa-onnx-core onnxruntime_providers_cuda + onnxruntime_providers_shared ) endif()