From 5489325df9f07af5f39cce101a91cee7fad2eb62 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 16 Nov 2023 10:09:09 +0800 Subject: [PATCH] Add Windows GPU CI (#600) * set cuda * update * update * win cuda * cuda_path * print log * update * vsintegration * CUDA toolkit dir * update * update * win GPU * fix typo * 1.16.1 * test * update comments * rm useless steps --------- Co-authored-by: Wenbing Li <10278425+wenbingl@users.noreply.github.com> --- .pipelines/ci.yml | 48 +++++++++++++++++++++++++++++ .pipelines/scripts/set_env_cuda.bat | 17 ++++++++++ .pipelines/templates/set_winenv.yml | 27 ++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 .pipelines/scripts/set_env_cuda.bat create mode 100644 .pipelines/templates/set_winenv.yml diff --git a/.pipelines/ci.yml b/.pipelines/ci.yml index 8dbfe31e..2ed1f244 100644 --- a/.pipelines/ci.yml +++ b/.pipelines/ci.yml @@ -473,6 +473,54 @@ stages: python -m pytest --ignore=test_cv2.py --ignore=test_tools_add_pre_post_processing_to_model.py . --verbose displayName: Run python test +- stage: WindowsCUDABuilds + dependsOn: [] + jobs: + - job: WindowsC + pool: + name: 'onnxruntime-extensions-Win2022-GPU-A10' + variables: + ORT_VERSION: '1.16.2' + steps: + - template: templates/set_winenv.yml + parameters: + EnvSetupScript: 'set_env_cuda.bat' + DownloadCUDA: true + + - script: | + nvidia-smi + nvcc --version + where nvcc + displayName: check cuda version + + - task: DownloadGitHubRelease@0 + inputs: + connection: 'GitHub - Release' + userRepository: 'microsoft/onnxruntime' + defaultVersionType: 'specificTag' + version: 'v$(ORT_VERSION)' + itemPattern: '*-win-x64-gpu-$(ORT_VERSION)*' + downloadPath: '$(Build.SourcesDirectory)' + displayName: Download the ONNXRuntime prebuilt package. + + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '**/*.zip' + destinationFolder: '$(Build.SourcesDirectory)' + cleanDestinationFolder: false + overwriteExistingFiles: true + displayName: Unpack ONNXRuntime package. + + - script: | + set CUDA_PATH=$(Agent.TempDirectory)\v11.8 + call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-gpu-$(ORT_VERSION) + displayName: build the customop library with onnxruntime + + - script: | + cd out/Windows + ctest -C RelWithDebInfo --output-on-failure + displayName: Run C++ native tests + - stage: WebAssemblyBuilds dependsOn: [] jobs: diff --git a/.pipelines/scripts/set_env_cuda.bat b/.pipelines/scripts/set_env_cuda.bat new file mode 100644 index 00000000..46873c24 --- /dev/null +++ b/.pipelines/scripts/set_env_cuda.bat @@ -0,0 +1,17 @@ +REM Copyright (c) Microsoft Corporation. All rights reserved. +REM Licensed under the MIT License. + +if exist PATH=%AGENT_TEMPDIRECTORY%\v11.8\ ( + set PATH=%AGENT_TEMPDIRECTORY%\v11.8\bin;%AGENT_TEMPDIRECTORY%\v11.8\extras\CUPTI\lib64;%PATH% +) else ( + set PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\extras\CUPTI\lib64;%PATH% +) + +@REM The default version is still cuda v11.8, because set cuda v12.2 after it +if exist PATH=%AGENT_TEMPDIRECTORY%\v12.2\ ( + set PATH=%PATH%;%AGENT_TEMPDIRECTORY%\v12.2\bin;%AGENT_TEMPDIRECTORY%\v12.2\extras\CUPTI\lib64 +) else ( + set PATH=%PATH%;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\extras\CUPTI\lib64 +) + +set GRADLE_OPTS=-Dorg.gradle.daemon=false diff --git a/.pipelines/templates/set_winenv.yml b/.pipelines/templates/set_winenv.yml new file mode 100644 index 00000000..b76c5034 --- /dev/null +++ b/.pipelines/templates/set_winenv.yml @@ -0,0 +1,27 @@ +parameters: + - name: EnvSetupScript + type: string + - name: DownloadCUDA + type: boolean + default: false + - name: PrimaryCUDAVersion + type: string + default: '11.8' + - name: SecondaryCUDAVersion + type: string + default: '12.2' + +steps: + - ${{ if eq(parameters.DownloadCUDA, 'true') }}: + - powershell: | + azcopy.exe cp --recursive "https://lotusscus.blob.core.windows.net/models/cuda_sdk/v${{ parameters.PrimaryCUDAVersion }}" $(Agent.TempDirectory) + displayName: 'Download Primary CUDA SDK v${{ parameters.PrimaryCUDAVersion }}' + - powershell: | + azcopy.exe cp --recursive "https://lotusscus.blob.core.windows.net/models/cuda_sdk/v${{ parameters.SecondaryCUDAVersion }}" $(Agent.TempDirectory) + displayName: 'Download Secondary CUDA SDK v${{ parameters.SecondaryCUDAVersion }}' + - task: BatchScript@1 + displayName: 'setup env' + inputs: + filename: '$(Build.SourcesDirectory)\.pipelines\scripts\${{ parameters.EnvSetupScript }}' + modifyEnvironment: true + workingFolder: '$(Build.BinariesDirectory)' \ No newline at end of file