From b71554c6dc2d89cdb5aab316db516fa424438032 Mon Sep 17 00:00:00 2001 From: Yufeng Li Date: Thu, 5 Mar 2020 14:51:09 -0800 Subject: [PATCH] Cherry pick PR 3120 and 3131 to rel-1.2.0 (#3137) * Enable DML Nuget Package for x64 or x86 architectures (#3120) * add dml gpu pipelines * add x86 to the gpu dml dev build pipeline * Enable DML x86 builds * Fix uint64_t -> size_t warning * fix warnings * enable dml on x86 ci builds * operatorHelper 773 error uint32_t vs uint64_t * operatorHelper 773 error uint32_t vs uint64_t * make x86 pipeline use the gpu pool * more warnings * fix x86 directml path * make dml nuget package * disable tf_pnasnet_large * disable zfnet512 * make validation use wildcards * disable x86 dml gpu tests * add args. * update gpu.yml * change nupkg wildcard * add debug statements * package x86 dml nupkg * dont drop managed nuget again from dml pipeline build * Add DML EULA * directml license should be renamed to not clobber the existing license * casing on dml package.... * {} to () * fix license name * disable dml from x86 ci * typo and cr feedback * remove featurizers * ship the dml pdb as well * Fix CUDA PATH (#3131) Previously, we put the "bin" folder of all the CUDA verions in the system PATH. And 10.2 is in the front. It's a mess. So I've removed all of them from the system PATH env. But I need to add one of them back through build scripts. (The problem only affect the C# test, not the C/C++ tests that forked from build.py). Co-authored-by: smk2007 Co-authored-by: Changming Sun --- cmake/onnxruntime_common.cmake | 2 +- cmake/onnxruntime_providers.cmake | 1 + csharp/OnnxRuntime.CSharp.proj | 8 +- .../Microsoft.ML.OnnxRuntime.csproj | 20 ++-- .../src/DmlCommandRecorder.cpp | 4 +- .../src/ExecutionProvider.cpp | 2 +- .../src/FusedGraphKernel.cpp | 4 +- .../src/Operators/DmlOperator.cpp | 4 +- .../OperatorAuthorHelper/OperatorHelper.cpp | 10 +- .../dml/OperatorAuthorHelper/OperatorHelper.h | 2 +- onnxruntime/test/onnx/main.cc | 2 +- .../azure-pipelines-py-packaging.yml | 2 +- .../c-api-packaging-pipelines.yml | 2 +- .../azure-pipelines/nuget/templates/gpu.yml | 105 +++++++++++++++++- .../nuget/templates/test_win.yml | 2 +- .../templates/validate-nuget.yml | 3 +- .../azure-pipelines/templates/win-ci-2019.yml | 27 +++-- .../azure-pipelines/win-gpu-ci-pipeline.yml | 2 +- .../win-gpu-tensorrt-ci-pipeline.yml | 2 +- .../github/windows/setup_env_cuda.bat | 2 + .../ci_build/github/windows/setup_env_trt.bat | 2 + .../nuget/generate_nuspec_for_native_nuget.py | 6 +- tools/nuget/validate_nuget.py | 4 +- 23 files changed, 167 insertions(+), 51 deletions(-) create mode 100644 tools/ci_build/github/windows/setup_env_cuda.bat create mode 100644 tools/ci_build/github/windows/setup_env_trt.bat diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index d33e9e1412..d8c29a2047 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -56,7 +56,7 @@ elseif(onnxruntime_target_platform STREQUAL "ARM" OR CMAKE_GENERATOR MATCHES "AR set(onnxruntime_target_platform "ARM") elseif(onnxruntime_target_platform STREQUAL "x64" OR onnxruntime_target_platform STREQUAL "x86_64" OR onnxruntime_target_platform STREQUAL "AMD64" OR CMAKE_GENERATOR MATCHES "Win64") set(onnxruntime_target_platform "x64") -elseif(onnxruntime_target_platform STREQUAL "x86" OR onnxruntime_target_platform STREQUAL "i386" OR onnxruntime_target_platform STREQUAL "i686") +elseif(onnxruntime_target_platform STREQUAL "Win32" OR onnxruntime_target_platform STREQUAL "x86" OR onnxruntime_target_platform STREQUAL "i386" OR onnxruntime_target_platform STREQUAL "i686") set(onnxruntime_target_platform "x86") endif() diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index b2b4c57960..ee0c7b2ce3 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -435,6 +435,7 @@ if (onnxruntime_USE_DML) if(NOT onnxruntime_target_platform STREQUAL "x86" AND NOT onnxruntime_target_platform STREQUAL "x64") message(FATAL_ERROR "Target platform ${onnxruntime_target_platform} is not supported by DML") endif() + foreach(file "DirectML.dll" "DirectML.pdb" "DirectML.Debug.dll" "DirectML.Debug.pdb") add_custom_command(TARGET onnxruntime_providers_dml POST_BUILD diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index 96d7d31ba4..3f583996e4 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -18,8 +18,9 @@ CMake creates a target to this project false - .. + .. ..\build\Windows + $(OnnxRuntimeBuildDirectory)\packages $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration) @@ -87,6 +88,9 @@ CMake creates a target to this project + + + @@ -107,7 +111,7 @@ CMake creates a target to this project Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId)"/> - + diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index b74ed6e771..669497220c 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -92,8 +92,8 @@ CopyToOutputDirectory="Always" Visible="false" /> - - - - Alloc(temporaryResourceSize, AllocatorRoundingMode::Enabled); + void* tempResourceHandle = allocator->Alloc(static_cast(temporaryResourceSize), AllocatorRoundingMode::Enabled); if (!tempResourceHandle) { THROW_HR(E_OUTOFMEMORY); @@ -137,7 +137,7 @@ void DmlCommandRecorder::ExecuteOperator( // Allocate and immediately free a temporary buffer. The buffer resource will still be // alive (managed by the pool); freeing allows the resource to be shared with other operators. - void* tempResourceHandle = allocator->Alloc(temporaryResourceSize, AllocatorRoundingMode::Enabled); + void* tempResourceHandle = allocator->Alloc(static_cast(temporaryResourceSize), AllocatorRoundingMode::Enabled); if (!tempResourceHandle) { THROW_HR(E_OUTOFMEMORY); diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp index 84b298ca77..d7428c698b 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp @@ -455,7 +455,7 @@ namespace Dml { assert(!m_closed); - m_uploadHeap->BeginUploadToGpu(dstData, 0, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, AsByteSpan(srcData, srcDataSize)); + m_uploadHeap->BeginUploadToGpu(dstData, 0, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, AsByteSpan(srcData, static_cast(srcDataSize))); return S_OK; } diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/FusedGraphKernel.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/FusedGraphKernel.cpp index 9391e191de..619ed2f4ba 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/FusedGraphKernel.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/FusedGraphKernel.cpp @@ -289,7 +289,7 @@ namespace Dml if (persistentResourceSize > 0) { THROW_IF_FAILED(m_provider->AllocatePooledResource( - persistentResourceSize, + static_cast(persistentResourceSize), AllocatorRoundingMode::Disabled, m_persistentResource.GetAddressOf(), m_persistentResourceAllocatorUnk.GetAddressOf())); @@ -589,7 +589,7 @@ namespace Dml // which is scheduled up to the point that this method returns has completed. ComPtr tempAlloc; uint64_t tempAllocId = 0; - THROW_IF_FAILED(contextWrapper.AllocateTemporaryData(execBindingProps.TemporaryResourceSize, tempAlloc.GetAddressOf(), &tempAllocId)); + THROW_IF_FAILED(contextWrapper.AllocateTemporaryData(static_cast(execBindingProps.TemporaryResourceSize), tempAlloc.GetAddressOf(), &tempAllocId)); ComPtr tempResourceUnk; m_winmlProvider->GetABIDataInterface(false, tempAlloc.Get(), &tempResourceUnk); diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperator.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperator.cpp index 6b1a4b0dc8..a44e11dbc2 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperator.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperator.cpp @@ -80,7 +80,7 @@ namespace Dml if (persistentResourceSize > 0) { THROW_IF_FAILED(m_executionProvider->AllocatePooledResource( - persistentResourceSize, + static_cast(persistentResourceSize), AllocatorRoundingMode::Enabled, m_persistentResource.GetAddressOf(), m_persistentResourcePoolingUnk.GetAddressOf())); @@ -117,7 +117,7 @@ namespace Dml { m_persistentResource = nullptr; THROW_IF_FAILED(m_executionProvider->AllocatePooledResource( - persistentResourceSize, + static_cast(persistentResourceSize), AllocatorRoundingMode::Enabled, m_persistentResource.GetAddressOf(), m_persistentResourcePoolingUnk.GetAddressOf())); diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp index 9f3a0ed7e6..5924c063b7 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp @@ -374,7 +374,7 @@ int64_t ReadAsInt64(MLOperatorTensorDataType tensorDataType, const void* p) ) { const uint32_t inputDimCount = gsl::narrow_cast(inputDimensions.size()); - m_axis = HandleNegativeAxis(operatorAttributes.GetOptionalAttribute(AttrName::Axis, 0), inputDimCount); + m_axis = static_cast(HandleNegativeAxis(operatorAttributes.GetOptionalAttribute(AttrName::Axis, 0), inputDimCount)); m_split = operatorAttributes.GetOptionalAttributeVectorInt32(AttrName::Split); } @@ -768,9 +768,9 @@ int64_t ReadAsInt64(MLOperatorTensorDataType tensorDataType, const void* p) gsl::span inputDimensions ) { - int32_t inputDimCount = gsl::narrow_cast(inputDimensions.size()); - m_axis = HandleNegativeAxis(operatorAttributes.GetOptionalAttribute(AttrName::Axis, -1), inputDimCount); - ML_CHECK_VALID_ARGUMENT(m_axis < inputDimensions.size()); + uint32_t inputDimCount = gsl::narrow_cast(inputDimensions.size()); + m_axis = static_cast(HandleNegativeAxis(operatorAttributes.GetOptionalAttribute(AttrName::Axis, -1), inputDimCount)); + ML_CHECK_VALID_ARGUMENT(m_axis < static_cast(inputDimensions.size())); } std::vector ConcatHelper::GetOutputShapes(const MLShapeInferenceContext& shapeInfo) const @@ -864,7 +864,7 @@ int64_t ReadAsInt64(MLOperatorTensorDataType tensorDataType, const void* p) int32_t inputDimCount = gsl::narrow_cast(inputDimensions.size()); int32_t axis = operatorAttributes.GetOptionalAttribute(AttrName::Axis, 1); // Flatten can accept an axis [-r, r], including one past the last absolute index. - m_axis = (axis == inputDimCount) ? axis : HandleNegativeAxis(axis, inputDimCount); + m_axis = (axis == inputDimCount) ? axis : static_cast(HandleNegativeAxis(axis, inputDimCount)); } std::vector FlattenHelper::GetOutputShapes(const MLShapeInferenceContext& shapeInfo) const diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h index aa8486117f..c9f889f179 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.h @@ -607,7 +607,7 @@ public: { dimIndex = axes[i]; } - ML_CHECK_VALID_ARGUMENT(dimIndex < inputDimensions.size(), "'axes' must be valid with within actual input dimensions."); + ML_CHECK_VALID_ARGUMENT(dimIndex < static_cast(inputDimensions.size()), "'axes' must be valid with within actual input dimensions."); // Positive values are offsets from 0. // Negative values are offsets from the dimension's size. diff --git a/onnxruntime/test/onnx/main.cc b/onnxruntime/test/onnx/main.cc index 8eaa81fe2d..ff586ec2db 100644 --- a/onnxruntime/test/onnx/main.cc +++ b/onnxruntime/test/onnx/main.cc @@ -396,7 +396,7 @@ int real_main(int argc, char* argv[], Ort::Env& env) { static const ORTCHAR_T* cuda_flaky_tests[] = { ORT_TSTR("fp16_inception_v1"), ORT_TSTR("fp16_shufflenet"), ORT_TSTR("fp16_tiny_yolov2")}; - static const ORTCHAR_T* dml_disabled_tests[] = {ORT_TSTR("mlperf_ssd_resnet34_1200"), ORT_TSTR("mlperf_ssd_mobilenet_300"), ORT_TSTR("mask_rcnn"), ORT_TSTR("faster_rcnn")}; + static const ORTCHAR_T* dml_disabled_tests[] = {ORT_TSTR("mlperf_ssd_resnet34_1200"), ORT_TSTR("mlperf_ssd_mobilenet_300"), ORT_TSTR("mask_rcnn"), ORT_TSTR("faster_rcnn"), ORT_TSTR("tf_pnasnet_large"), ORT_TSTR("zfnet512")}; static const ORTCHAR_T* dnnl_disabled_tests[] = {ORT_TSTR("test_densenet121"), ORT_TSTR("test_resnet18v2"), ORT_TSTR("test_resnet34v2"), ORT_TSTR("test_resnet50v2"), ORT_TSTR("test_resnet101v2"), ORT_TSTR("test_resnet101v2"), ORT_TSTR("test_vgg19"), ORT_TSTR("tf_inception_resnet_v2"), ORT_TSTR("tf_inception_v1"), ORT_TSTR("tf_inception_v3"), ORT_TSTR("tf_inception_v4"), ORT_TSTR("tf_mobilenet_v1_1.0_224"), ORT_TSTR("tf_mobilenet_v2_1.0_224"), ORT_TSTR("tf_mobilenet_v2_1.4_224"), ORT_TSTR("tf_nasnet_large"), ORT_TSTR("tf_pnasnet_large"), ORT_TSTR("tf_resnet_v1_50"), ORT_TSTR("tf_resnet_v1_101"), ORT_TSTR("tf_resnet_v1_101"), diff --git a/tools/ci_build/github/azure-pipelines/azure-pipelines-py-packaging.yml b/tools/ci_build/github/azure-pipelines/azure-pipelines-py-packaging.yml index 952100e917..f16e3bcc5c 100644 --- a/tools/ci_build/github/azure-pipelines/azure-pipelines-py-packaging.yml +++ b/tools/ci_build/github/azure-pipelines/azure-pipelines-py-packaging.yml @@ -216,7 +216,7 @@ jobs: timeoutInMinutes: 60 variables: CUDA_VERSION: '10.1' - EnvSetupScript: setup_env.bat + EnvSetupScript: setup_env_cuda.bat strategy: matrix: Python35: diff --git a/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml index cf68b5bc62..941ebac632 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml @@ -165,7 +165,7 @@ jobs: pool: 'Win-GPU-2019' timeoutInMinutes: 120 variables: - EnvSetupScript: setup_env.bat + EnvSetupScript: setup_env_cuda.bat buildArch: x64 msbuildArch: amd64 msbuildPlatform: x64 diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml index 516eb64042..345ef38a43 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/gpu.yml @@ -11,7 +11,7 @@ jobs: BuildCommand: --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --use_telemetry --cmake_generator "Visual Studio 16 2019" --use_cuda --cuda_version=10.1 --cuda_home="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1" --cudnn_home="C:\local\cudnn-10.1-windows10-x64-v7.6.5.32\cuda" BuildArch: 'x64' msbuildArchitecture: 'amd64' - EnvSetupScript: 'setup_env.bat' + EnvSetupScript: 'setup_env_cuda.bat' sln_platform: 'x64' DoDebugBuild: 'false' DoNugetPack : 'true' @@ -26,6 +26,51 @@ jobs: mkdir $(Build.ArtifactStagingDirectory)\testdata copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\custom_op_library.* $(Build.ArtifactStagingDirectory)\testdata +- template: ../../templates/win-ci-2019.yml + parameters: + AgentPool : 'Win-GPU-2019' + ArtifactName: 'drop-nuget-dml' + JobName: 'Windows_CI_GPU_DML_Dev' + BuildCommand: --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --use_telemetry --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" + BuildArch: 'x64' + msbuildArchitecture: 'amd64' + EnvSetupScript: 'setup_env_cuda.bat' + sln_platform: 'x64' + DoDebugBuild: 'false' + DoNugetPack : 'true' + DoCompliance: 'false' + DoEsrp: ${{ parameters.DoEsrp }} + CudaVersion: '10.0' + OrtPackageId: 'Microsoft.ML.OnnxRuntime.DirectML' + NuPackScript: | + msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreatePackage /p:OrtPackageId=Microsoft.ML.OnnxRuntime.DirectML + copy $(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) + mkdir $(Build.ArtifactStagingDirectory)\testdata + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\custom_op_library.* $(Build.ArtifactStagingDirectory)\testdata + +- template: ../../templates/win-ci-2019.yml + parameters: + AgentPool : 'Win-GPU-2019' + ArtifactName: 'drop-win-dml-x86-zip' + JobName: 'Windows_CI_GPU_DML_Dev_x86' + BuildCommand: --build_dir $(Build.BinariesDirectory) --x86 --skip_submodule_sync --build_shared_lib --enable_onnx_tests --use_telemetry --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" + BuildArch: 'x86' + EnvSetupScript: 'setup_env_x86.bat' + sln_platform: 'Win32' + DoDebugBuild: 'false' + DoNugetPack : 'true' + DoCompliance: ${{ parameters.DoCompliance }} + DoEsrp: ${{ parameters.DoEsrp }} + RunTests: 'false' + NuPackScript: | + msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /p:TargetArchitecture=x86 /t:CreatePackage /p:OrtPackageId=Microsoft.ML.OnnxRuntime.DirectML + cd $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\ + ren Microsoft.ML.OnnxRuntime.DirectML.* win-dml-x86.zip + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\win-dml-x86.zip $(Build.ArtifactStagingDirectory) + mkdir $(Build.ArtifactStagingDirectory)\testdata + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\custom_op_library.* $(Build.ArtifactStagingDirectory)\testdata + - job: 'Linux_CI_GPU_Dev' workspace: clean: all @@ -68,15 +113,29 @@ jobs: pool: 'Win-GPU-2019' dependsOn: - Windows_CI_GPU_CUDA_Dev + - Windows_CI_GPU_DML_Dev + - Windows_CI_GPU_DML_Dev_x86 - Linux_CI_GPU_Dev condition: succeeded() steps: - task: DownloadPipelineArtifact@0 - displayName: 'Download Pipeline Artifact - NuGet' + displayName: 'Download Pipeline Artifact - NuGet CUDA' inputs: artifactName: 'drop-nuget' targetPath: '$(Build.BinariesDirectory)/nuget-artifact' + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact - NuGet DirectML' + inputs: + artifactName: 'drop-nuget-dml' + targetPath: '$(Build.BinariesDirectory)/nuget-artifact-dml' + + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact - NuGet DirectML x86' + inputs: + artifactName: 'drop-win-dml-x86-zip' + targetPath: '$(Build.BinariesDirectory)/nuget-artifact-dml' + - task: DownloadPipelineArtifact@0 displayName: 'Download Pipeline Artifact - Linux' inputs: @@ -110,6 +169,40 @@ jobs: copy $(Build.BinariesDirectory)\nuget-artifact\*.nupkg $(Build.ArtifactStagingDirectory) displayName: 'Bundle Native NuGet and other binaries' + - script: | + pushd $(Build.BinariesDirectory)\nuget-artifact-dml + dir + powershell -Command "Invoke-WebRequest http://stahlworks.com/dev/unzip.exe -OutFile unzip.exe" + powershell -Command "Invoke-WebRequest http://stahlworks.com/dev/zip.exe -OutFile zip.exe" + set PATH=%CD%;%PATH% + FOR /R %%i IN (*.nupkg) do ( + rename %%~ni.nupkg %%~ni.zip + unzip %%~ni.zip -d %%~ni + del /Q %%~ni.zip + + unzip win-dml-x86.zip -d win-x86 + mkdir %%~ni\runtimes\win-x86 + mkdir %%~ni\runtimes\win-x86\native + + move win-x86\runtimes\win-x86\native\onnxruntime.dll %%~ni\runtimes\win-x86\native\onnxruntime.dll + move win-x86\runtimes\win-x86\native\onnxruntime.lib %%~ni\runtimes\win-x86\native\onnxruntime.lib + move win-x86\runtimes\win-x86\native\onnxruntime.pdb %%~ni\runtimes\win-x86\native\onnxruntime.pdb + + move win-x86\runtimes\win-x86\native\windows.ai.machinelearning.dll %%~ni\runtimes\win-x86\native\windows.ai.machinelearning.dll + move win-x86\runtimes\win-x86\native\windows.ai.machinelearning.lib %%~ni\runtimes\win-x86\native\windows.ai.machinelearning.lib + move win-x86\runtimes\win-x86\native\windows.ai.machinelearning.pdb %%~ni\runtimes\win-x86\native\windows.ai.machinelearning.pdb + + move win-x86\runtimes\win-x86\native\directml.dll %%~ni\runtimes\win-x86\native\directml.dll + + pushd %%~ni + zip -r ..\%%~ni.zip . + popd + move %%~ni.zip %%~ni.nupkg + ) + popd + copy $(Build.BinariesDirectory)\nuget-artifact-dml\Microsoft.ML.OnnxRuntime.DirectML*nupkg $(Build.ArtifactStagingDirectory) + displayName: 'Bundle DML NuGet and other binaries' + - template: ../../templates/esrp_nuget.yml parameters: DisplayName: 'ESRP - sign NuGet package' @@ -119,9 +212,17 @@ jobs: - template: ../../templates/validate-nuget.yml parameters: NugetPath: '$(Build.ArtifactStagingDirectory)' + NugetPackage: 'Microsoft.ML.OnnxRuntime.Gpu*nupkg' PlatformsSupported: 'win-x64,linux-x64' VerifyNugetSigning: ${{ parameters.DoEsrp }} + - template: ../../templates/validate-nuget.yml + parameters: + NugetPath: '$(Build.ArtifactStagingDirectory)' + NugetPackage: 'Microsoft.ML.OnnxRuntime.DirectML*nupkg' + PlatformsSupported: 'win-x64,win-x86' + VerifyNugetSigning: ${{ parameters.DoEsrp }} + - task: PublishPipelineArtifact@0 displayName: 'Publish Pipeline NuGet Artifact' inputs: diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml index 10da77354d..572823ba2d 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_win.yml @@ -32,7 +32,7 @@ jobs: - task: BatchScript@1 displayName: 'setup env' inputs: - filename: '$(Build.SourcesDirectory)\tools\ci_build\github\windows\setup_env.bat' + filename: '$(Build.SourcesDirectory)\tools\ci_build\github\windows\setup_env_cuda.bat' modifyEnvironment: true workingFolder: '$(Build.BinariesDirectory)' diff --git a/tools/ci_build/github/azure-pipelines/templates/validate-nuget.yml b/tools/ci_build/github/azure-pipelines/templates/validate-nuget.yml index a162219f5b..9136cef1e8 100644 --- a/tools/ci_build/github/azure-pipelines/templates/validate-nuget.yml +++ b/tools/ci_build/github/azure-pipelines/templates/validate-nuget.yml @@ -2,6 +2,7 @@ parameters: NugetPath: '' PlatformsSupported: '' VerifyNugetSigning: '' + NugetPackage: '*' steps: - task: UsePythonVersion@0 @@ -13,5 +14,5 @@ steps: displayName: 'Validate Nuget' inputs: scriptPath: '$(Build.SourcesDirectory)\tools\nuget\validate_nuget.py' - arguments: '--nuget_path ${{parameters.NugetPath}} --platforms_supported ${{parameters.PlatformsSupported}} --verify_nuget_signing ${{parameters.VerifyNugetSigning}}' + arguments: '--nuget_package ${{parameters.NugetPackage}} --nuget_path ${{parameters.NugetPath}} --platforms_supported ${{parameters.PlatformsSupported}} --verify_nuget_signing ${{parameters.VerifyNugetSigning}}' workingDirectory: "$(Build.BinariesDirectory)" \ No newline at end of file diff --git a/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml b/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml index 8c9d2a8784..edebf88cdd 100644 --- a/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml +++ b/tools/ci_build/github/azure-pipelines/templates/win-ci-2019.yml @@ -15,6 +15,7 @@ parameters: AgentPool: 'Win-CPU-2019' AgentDemands: [] OrtPackageId: Microsoft.ML.OnnxRuntime + RunTests : 'true' jobs: - job: ${{ parameters.JobName }} timeoutInMinutes: 120 @@ -133,18 +134,20 @@ jobs: arguments: '--configuration RelWithDebInfo -p:Platform="Any CPU" -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=${{ parameters.OrtPackageId }}' workingDirectory: '$(Build.SourcesDirectory)\csharp' - - script: | - mklink /D /J $(Build.BinariesDirectory)\RelWithDebInfo\models $(Build.BinariesDirectory)\models - DIR dist\ /S /B > wheel_filename_file - set /p WHEEL_FILENAME= wheel_filename_file + set /p WHEEL_FILENAME=') - + files_list.append('') + files_list.append('') # Process onnxruntime import lib, dll, and pdb files_list.append('') diff --git a/tools/nuget/validate_nuget.py b/tools/nuget/validate_nuget.py index 458ae11a82..bd7babff93 100644 --- a/tools/nuget/validate_nuget.py +++ b/tools/nuget/validate_nuget.py @@ -11,6 +11,7 @@ def parse_arguments(): parser = argparse.ArgumentParser(description="Validate ONNX Runtime native nuget containing native shared library artifacts spec script", usage='') # Main arguments + parser.add_argument("--nuget_package", required=True, help="Nuget package name to be validated.") parser.add_argument("--nuget_path", required=True, help="Path containing the Nuget to be validated. Must only contain only one Nuget within this.") parser.add_argument("--platforms_supported", required=True, help="Comma separated list (no space). Ex: linux-x64,win-x86,osx-x64") parser.add_argument("--verify_nuget_signing", required=True, help="Flag inidicating if Nuget package signing is to be verified. Only accepets 'true' or 'false'") @@ -69,13 +70,12 @@ def check_if_nuget_is_signed(nuget_path): def main(): args = parse_arguments() - files = os.listdir(args.nuget_path) + files = glob.glob(os.path.join(args.nuget_path, args.nuget_package)) nuget_packages_found_in_path = [i for i in files if i.endswith('.nupkg') and "Managed" not in i] if (len(nuget_packages_found_in_path) != 1): print('Nuget packages found in path: ') print(nuget_packages_found_in_path) raise Exception('No Nuget packages / more than one Nuget packages found in the given path.') - nuget_file_name = nuget_packages_found_in_path[0] full_nuget_path = os.path.join(args.nuget_path, nuget_file_name)