From 9a54a61bf4cbd38f8b78d32957142e316aa1aae3 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 14 Oct 2023 16:11:55 +0900 Subject: [PATCH] =?UTF-8?q?=E6=AE=8B=E3=82=8A=E3=81=AE=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=82=B2=E3=83=83=E3=83=88=E3=82=92=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 103 +++++++++++++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b7e795..9461225 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,35 @@ jobs: fail-fast: false matrix: include: + - artifact_name: onnxruntime-win-x64 + os: windows-2019 + build_opts: --cmake_extra_defines CMAKE_SYSTEM_NAME=Windows CMAKE_SYSTEM_PROCESSOR=x86_64 --config Release --parallel --update --build --build_shared_lib + result_dir: build/Windows/Release + release_config: Release + - artifact_name: onnxruntime-win-x64-gpu-dml + os: windows-2019 + build_opts: --cmake_extra_defines CMAKE_SYSTEM_NAME=Windows CMAKE_SYSTEM_PROCESSOR=x86_64 --config Release --parallel --update --build --build_shared_lib --use_dml + result_dir: build/Windows/Release + release_config: Release + - artifact_name: onnxruntime-win-x64-gpu-cuda + os: windows-2019 + cuda_version: 11.8.0 + cudnn_url: https://developer.download.nvidia.com/compute/redist/cudnn/v8.5.0/local_installers/11.7/cudnn-windows-x86_64-8.5.0.96_cuda11-archive.zip + build_opts: --cmake_extra_defines CMAKE_SYSTEM_NAME=Windows CMAKE_SYSTEM_PROCESSOR=x86_64 --config Release --parallel --update --build --build_shared_lib --use_cuda --cuda_version 11.6.2 + result_dir: build/Windows/Release + release_config: Release + - artifact_name: onnxruntime-linux-x64 + os: ubuntu-20.04 + build_opts: --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=x86_64 --config Release --parallel --update --build --build_shared_lib + result_dir: build/Linux + release_config: Release + - artifact_name: onnxruntime-linux-x64-gpu + os: ubuntu-20.04 + cuda_version: 11.8.0 + cudnn_url: https://developer.download.nvidia.com/compute/redist/cudnn/v8.2.4/cudnn-11.4-linux-x64-v8.2.4.15.tgz + build_opts: --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=x86_64 --config Release --parallel --update --build --build_shared_lib --use_cuda + result_dir: build/Linux + release_config: Release - artifact_name: onnxruntime-linux-armhf os: ubuntu-20.04 cc_version: "8" @@ -52,6 +81,11 @@ jobs: build_opts: --arm64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=aarch64 --config Release --parallel --update --build --build_shared_lib result_dir: build/Linux release_config: Release + - artifact_name: onnxruntime-osx-x86_64 + os: macos-12 + build_opts: --cmake_extra_defines CMAKE_SYSTEM_NAME=Darwin CMAKE_SYSTEM_PROCESSOR=x86_64 --config Release --parallel --update --build --build_shared_lib + result_dir: build/MacOS + release_config: Release - artifact_name: onnxruntime-ios-arm64 os: macos-12 build_opts: --config Release --parallel --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphoneos --osx_arch arm64 --apple_deploy_target 16.0 @@ -110,7 +144,7 @@ jobs: key: ${{ matrix.artifact_name }}-v${{ env.ONNXRUNTIME_VERSION }}-cache-v1-${{ hashFiles('matrix.json') }} - name: Install build dependencies on ubuntu - if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') + if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') && matrix.arch run: | sudo apt-get update sudo apt-get install -y \ @@ -119,8 +153,7 @@ jobs: wget \ qemu-user-binfmt \ gcc-${{ matrix.cc_version }}${{ env.ARCH_SUFFIX }} \ - g++-${{ matrix.cxx_version }}${{ env.ARCH_SUFFIX }} \ - python3 + g++-${{ matrix.cxx_version }}${{ env.ARCH_SUFFIX }} - name: Install build dependencies on macos if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') @@ -128,6 +161,16 @@ jobs: # Workaround for protoc https://github.com/microsoft/onnxruntime/issues/16238#issuecomment-1590398821 brew install protobuf@21 + - name: Install Python 3.8 + if: steps.cache-build-result.outputs.cache-hit != 'true' + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install Python packages + if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url + run: python -m pip install -r tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/requirements.txt + # ONNX Runtime v1.15.1 requires CMake 3.26 or higher. - name: Install CMake if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') @@ -137,8 +180,45 @@ jobs: wget -O cmake.sh "https://github.com/Kitware/CMake/releases/download/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh" sudo bash cmake.sh --skip-license --prefix=/usr/local + - name: Set up CUDA + if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url + uses: Jimver/cuda-toolkit@v0.2.11 + with: + method: network + cuda: ${{ matrix.cuda_version }} + + - name: Set `$CUDA_HOME` + if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url + shell: bash + run: echo "CUDA_HOME=$CUDA_PATH" >> "$GITHUB_ENV" + + - name: Set up cuDNN + if: steps.cache-build-result.outputs.cache-hit != 'true' && matrix.cuda_version && matrix.cudnn_url + shell: bash + run: | + mkdir download + + if [ ${{ runner.os }} = Windows ]; then + curl -L "${{ matrix.cudnn_url }}" > download/cudnn.zip + unzip download/cudnn.zip -d download + rm download/cudnn.zip + else + curl -L "${{ matrix.cudnn_url }}" > download/cudnn.tar.gz + tar -Jxf download/cudnn.tar.gz -C download/ + rm download/cudnn.tar.gz + fi + + cudnn_path=$(find download -maxdepth 1 -name 'cudnn-*') + if [ ${{ runner.os }} = Windows ]; then + cudnn_path=$(cygpath -wa "$cudnn_path") + else + cudnn_path=$(realpath "$cudnn_path") + fi + + echo "CUDNN_HOME=$cudnn_path" >> "$GITHUB_ENV" + - name: Configure build environment - if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') + if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') && matrix.arch run: | # Required for arm build # https://github.com/microsoft/onnxruntime/issues/4189#issuecomment-642528278 @@ -155,8 +235,13 @@ jobs: echo "CC=${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}" >> "$GITHUB_ENV" echo "CXX=${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}" >> "$GITHUB_ENV" - - name: Build ONNX Runtime - if: steps.cache-build-result.outputs.cache-hit != 'true' + - name: Build ONNX Runtime (Windows) + if: steps.cache-build-result.outputs.cache-hit != 'true' && runner.os == 'Windows' + shell: cmd + run: .\build.bat ${{ matrix.build_opts }} + + - name: Build ONNX Runtime (non-Windows) + if: steps.cache-build-result.outputs.cache-hit != 'true' && runner.os != 'Windows' run: | # add --arm for gcc-8: https://github.com/microsoft/onnxruntime/issues/4189 # skip test: https://github.com/microsoft/onnxruntime/issues/2436 @@ -170,9 +255,11 @@ jobs: rm -rf ${{ matrix.result_dir }}/${{ matrix.artifact_name }} rm -rf ./artifact # Set library name - if [[ ${{ matrix.artifact_name }} == onnxruntime-linux-* ]]; then + if [[ ${{ matrix.artifact_name }} == onnxruntime-win-* ]]; then + ONNXRUNTIME_NAME=onnxruntime.dll + elif [[ ${{ matrix.artifact_name }} == onnxruntime-linux-* ]]; then ONNXRUNTIME_NAME=libonnxruntime.so.${{ env.ONNXRUNTIME_VERSION }} - elif [[ ${{ matrix.artifact_name }} == onnxruntime-ios-* ]]; then + elif [[ ${{ matrix.artifact_name }} == onnxruntime-osx-* ]] || [[ ${{ matrix.artifact_name }} == onnxruntime-ios-* ]]; then ONNXRUNTIME_NAME=libonnxruntime.${{ env.ONNXRUNTIME_VERSION }}.dylib else echo "Unknown target found : ${{ matrix.artifact_name }}"