From de152edaa11676bac3e8c776efb754742c5507da Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 5 Dec 2023 11:27:49 +0800 Subject: [PATCH 01/42] use flexdownload --- .../c-api-noopenmp-packaging-pipelines.yml | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index f3c7930aa1ec7..066c749ac54d4 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -710,35 +710,46 @@ stages: steps: - checkout: self submodules: true - - task: DownloadPipelineArtifact@2 - displayName: 'Download Pipeline Artifact - NuGet' - inputs: - artifactName: 'onnxruntime-win-x64-cuda' - targetPath: '$(Build.BinariesDirectory)/nuget-artifact' - - task: DownloadPipelineArtifact@2 - displayName: 'Download Pipeline Artifact - NuGet' - inputs: - artifactName: 'onnxruntime-win-x64-tensorrt' - targetPath: '$(Build.BinariesDirectory)/nuget-artifact' + - template: templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact - NuGet' + ArtifactName: 'onnxruntime-win-x64-cuda' + TargetPath: '$(Build.BinariesDirectory)/nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - - task: DownloadPipelineArtifact@2 - displayName: 'Download Pipeline Artifact - NuGet' - inputs: - artifactName: 'onnxruntime-linux-x64-cuda' - targetPath: '$(Build.BinariesDirectory)/nuget-artifact' + - template: templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact - NuGet' + ArtifactName: 'onnxruntime-win-x64-tensorrt' + TargetPath: '$(Build.BinariesDirectory)/nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - - task: DownloadPipelineArtifact@2 - displayName: 'Download Pipeline Artifact - NuGet' - inputs: - artifactName: 'onnxruntime-linux-x64-tensorrt' - targetPath: '$(Build.BinariesDirectory)/nuget-artifact' + - template: templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact - NuGet' + ArtifactName: 'onnxruntime-linux-x64-cuda' + TargetPath: '$(Build.BinariesDirectory)/nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - - task: DownloadPipelineArtifact@2 - displayName: 'Download Pipeline Artifact - NuGet' - inputs: - artifactName: 'drop-extra' - targetPath: '$(Build.BinariesDirectory)/extra-artifact' + - template: templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact - NuGet' + ArtifactName: 'onnxruntime-linux-x64-tensorrt' + TargetPath: '$(Build.BinariesDirectory)/nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} + + - template: templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact - NuGet' + ArtifactName: 'drop-extra' + TargetPath: '$(Build.BinariesDirectory)/extra-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} # Reconstruct the build dir - task: PowerShell@2 From e0f8f6c8b1c9f4a727e7636d1079d1d3512d258a Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 7 Dec 2023 11:56:33 +0800 Subject: [PATCH 02/42] add dependency --- tools/nuget/generate_nuspec_for_native_nuget.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index df74e7e5599a8..15518d4ca5595 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -218,18 +218,27 @@ def generate_dependencies(xml_text, package_name, version): # Support .Net Core xml_text.append('') xml_text.append('') + if package_name == "Microsoft.ML.OnnxRuntime.Gpu": + xml_text.append('') + xml_text.append('') if include_dml: xml_text.append(dml_dependency) xml_text.append("") # Support .Net Standard xml_text.append('') xml_text.append('') + if package_name == "Microsoft.ML.OnnxRuntime.Gpu": + xml_text.append('') + xml_text.append('') if include_dml: xml_text.append(dml_dependency) xml_text.append("") # Support .Net Framework xml_text.append('') xml_text.append('') + if package_name == "Microsoft.ML.OnnxRuntime.Gpu": + xml_text.append('') + xml_text.append('') if include_dml: xml_text.append(dml_dependency) xml_text.append("") From e3806e2d290385c66a8a83b6229d7a025e337f83 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 8 Dec 2023 14:42:05 +0800 Subject: [PATCH 03/42] mv CUDA runtime --- .../nuget/generate_nuspec_for_native_nuget.py | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 15518d4ca5595..79a908559ce68 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -39,7 +39,9 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # Currently we take onnxruntime_providers_cuda from CUDA build # And onnxruntime, onnxruntime_providers_shared and # onnxruntime_providers_tensorrt from tensorrt build -def is_this_file_needed(ep, filename): +def is_this_file_needed(ep, filename, package_name): + if package_name == "Microsoft.ML.OnnxRuntime.Gpu": + return False return (ep != "cuda" or "cuda" in filename) and (ep != "tensorrt" or "cuda" not in filename) @@ -47,7 +49,7 @@ def is_this_file_needed(ep, filename): # ep: cuda, tensorrt, None # files_list: a list of xml string pieces to append # This function has no return value. It updates files_list directly -def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package): +def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package, package_name): for child in nuget_artifacts_dir.iterdir(): if not child.is_dir(): continue @@ -57,7 +59,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] - if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name): + if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name): files_list.append( '' % cpu_arch ) @@ -83,7 +85,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name): + if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name): files_list.append( '' % cpu_arch ) @@ -333,6 +335,8 @@ def generate_files(line_list, args): ] is_mklml_package = args.package_name == "Microsoft.ML.OnnxRuntime.MKLML" is_cuda_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu" + is_cuda_gpu_win_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" + is_cuda_gpu_linux_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-Linux" is_rocm_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.ROCm" is_dml_package = args.package_name == "Microsoft.ML.OnnxRuntime.DirectML" is_windowsai_package = args.package_name == "Microsoft.AI.MachineLearning" @@ -398,23 +402,25 @@ def generate_files(line_list, args): runtimes = f'{runtimes_target}{args.target_architecture}\\{runtimes_native_folder}"' # Process headers + build_dir = "buildTransitive" if "Microsoft.ML.OnnxRuntime.Gpu" in args.package_name else "build" + include_dir = f"{build_dir}\\native\\include" files_list.append( "' + + '" target="' + include_dir + '" />' ) files_list.append( "' + + '" target="' + include_dir + '" />' ) files_list.append( "' + + '" target="' + include_dir + '" />' ) if is_training_package: @@ -547,7 +553,7 @@ def generate_files(line_list, args): else: ep_list = [None] for ep in ep_list: - generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package) + generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package, args.package_name) is_ado_packaging_build = True else: # Code path for local dev build @@ -741,7 +747,8 @@ def generate_files(line_list, args): + '\\native" />' ) - if args.execution_provider == "cuda" or is_cuda_gpu_package and not is_ado_packaging_build: + if args.execution_provider == "cuda" or is_cuda_gpu_win_package and not is_ado_packaging_build: + print(f"is_cuda_gpu_win_package is {is_cuda_gpu_win_package}") files_list.append( "') # Process native targets files_list.append("') @@ -886,9 +893,10 @@ def generate_files(line_list, args): args.package_name + ".props", ) os.system(copy_command + " " + source_props + " " + target_props) - files_list.append("') + files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') + files_list.append("') + files_list.append("') # Process targets file source_targets = os.path.join( @@ -904,9 +912,10 @@ def generate_files(line_list, args): args.package_name + ".targets", ) os.system(copy_command + " " + source_targets + " " + target_targets) - files_list.append("') + files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') + files_list.append("') + files_list.append("') # Process xamarin targets files if args.package_name == "Microsoft.ML.OnnxRuntime": From d3e907f3a44e4cbe22eb57f93bbbb78a32cb696c Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Mon, 11 Dec 2023 09:38:48 +0800 Subject: [PATCH 04/42] runtime --- .../nuget/generate_nuspec_for_native_nuget.py | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 79a908559ce68..86854d3629200 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -39,6 +39,7 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # Currently we take onnxruntime_providers_cuda from CUDA build # And onnxruntime, onnxruntime_providers_shared and # onnxruntime_providers_tensorrt from tensorrt build +# cuda binaries are in dependent packages not in Microst.ML.OnnxRuntime.Gpu def is_this_file_needed(ep, filename, package_name): if package_name == "Microsoft.ML.OnnxRuntime.Gpu": return False @@ -59,7 +60,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] - if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name): + if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu-linux": files_list.append( '' % cpu_arch ) @@ -85,7 +86,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name): + if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu-win": files_list.append( '' % cpu_arch ) @@ -195,6 +196,14 @@ def generate_repo_url(line_list, repo_url, commit_id): line_list.append('') +def add_common_dependencies(xml_text, package_name, version): + dependent_packages = True if package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" else False + if not dependent_packages: + xml_text.append('') + if package_name == "Microsoft.ML.OnnxRuntime.Gpu": + xml_text.append('') + xml_text.append('') + def generate_dependencies(xml_text, package_name, version): dml_dependency = '' @@ -217,30 +226,22 @@ def generate_dependencies(xml_text, package_name, version): include_dml = package_name == "Microsoft.ML.OnnxRuntime.DirectML" xml_text.append("") + # Support .Net Core xml_text.append('') - xml_text.append('') - if package_name == "Microsoft.ML.OnnxRuntime.Gpu": - xml_text.append('') - xml_text.append('') + add_common_dependencies(xml_text, package_name, version) if include_dml: xml_text.append(dml_dependency) xml_text.append("") # Support .Net Standard xml_text.append('') - xml_text.append('') - if package_name == "Microsoft.ML.OnnxRuntime.Gpu": - xml_text.append('') - xml_text.append('') + add_common_dependencies(xml_text, package_name, version) if include_dml: xml_text.append(dml_dependency) xml_text.append("") # Support .Net Framework xml_text.append('') - xml_text.append('') - if package_name == "Microsoft.ML.OnnxRuntime.Gpu": - xml_text.append('') - xml_text.append('') + add_common_dependencies(xml_text, package_name, version) if include_dml: xml_text.append(dml_dependency) xml_text.append("") @@ -336,7 +337,7 @@ def generate_files(line_list, args): is_mklml_package = args.package_name == "Microsoft.ML.OnnxRuntime.MKLML" is_cuda_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu" is_cuda_gpu_win_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" - is_cuda_gpu_linux_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-Linux" + is_cuda_gpu_linux_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" is_rocm_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.ROCm" is_dml_package = args.package_name == "Microsoft.ML.OnnxRuntime.DirectML" is_windowsai_package = args.package_name == "Microsoft.AI.MachineLearning" @@ -546,7 +547,7 @@ def generate_files(line_list, args): if nuget_artifacts_dir.exists(): # Code path for ADO build pipeline, the files under 'nuget-artifacts' are # downloaded from other build jobs - if is_cuda_gpu_package: + if is_cuda_gpu_package or is_cuda_gpu_win_package or is_cuda_gpu_linux_package: ep_list = ["tensorrt", "cuda", None] elif is_rocm_gpu_package: ep_list = ["rocm", None] @@ -748,7 +749,6 @@ def generate_files(line_list, args): ) if args.execution_provider == "cuda" or is_cuda_gpu_win_package and not is_ado_packaging_build: - print(f"is_cuda_gpu_win_package is {is_cuda_gpu_win_package}") files_list.append( "') + files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') - files_list.append("') + files_list.append("') + files_list.append("') # Process targets file source_targets = os.path.join( @@ -912,10 +912,10 @@ def generate_files(line_list, args): args.package_name + ".targets", ) os.system(copy_command + " " + source_targets + " " + target_targets) - files_list.append("') + files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') - files_list.append("') + files_list.append("') + files_list.append("') # Process xamarin targets files if args.package_name == "Microsoft.ML.OnnxRuntime": From 8f2fa45b013d570a7bcca76121ec9c00770184ff Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Mon, 11 Dec 2023 10:36:43 +0800 Subject: [PATCH 05/42] add new msbuild task --- .../c-api-noopenmp-packaging-pipelines.yml | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 066c749ac54d4..eb17a28adb281 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -806,7 +806,7 @@ stages: DoEsrp: ${{ parameters.DoEsrp }} - task: MSBuild@1 - displayName: 'Build Nuget Packages' + displayName: 'Build Primary Nuget Packages Microsoft.ML.OnnxRuntime.Gpu' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo @@ -814,6 +814,24 @@ stages: msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' + - task: MSBuild@1 + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu-win' + inputs: + solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' + configuration: RelWithDebInfo + platform: 'Any CPU' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-win -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + workingDirectory: '$(Build.SourcesDirectory)\csharp' + + - task: MSBuild@1 + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu-linux' + inputs: + solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' + configuration: RelWithDebInfo + platform: 'Any CPU' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-win -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + workingDirectory: '$(Build.SourcesDirectory)\csharp' + - task: BatchScript@1 displayName: 'Add TensorRT header file to the native nuGet package' inputs: From 2e180d5b41e57bf999706e58f94d43b90705544b Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Mon, 11 Dec 2023 11:02:51 +0800 Subject: [PATCH 06/42] temp disable package validation --- .../c-api-noopenmp-packaging-pipelines.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index eb17a28adb281..e1f863cbc8d79 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -865,13 +865,13 @@ stages: FolderPath: '$(Build.ArtifactStagingDirectory)' DoEsrp: ${{ parameters.DoEsrp }} - - template: templates/validate-package.yml - parameters: - PackageType: 'nuget' - PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.*nupkg' - PlatformsSupported: 'win-x64,linux-x64' - VerifyNugetSigning: false + #- template: templates/validate-package.yml + # parameters: + # PackageType: 'nuget' + # PackagePath: '$(Build.ArtifactStagingDirectory)' + # PackageName: 'Microsoft.ML.OnnxRuntime.*nupkg' + # PlatformsSupported: 'win-x64,linux-x64' + # VerifyNugetSigning: false - task: PublishPipelineArtifact@0 displayName: 'Publish Pipeline NuGet Artifact' From 8f199e78b96e1ea9787b47bfac94b06dbb72c150 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Mon, 11 Dec 2023 11:29:02 +0800 Subject: [PATCH 07/42] typo --- .../azure-pipelines/c-api-noopenmp-packaging-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index e1f863cbc8d79..9497c7f388525 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -829,7 +829,7 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-win -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: BatchScript@1 From 2a69f777c53a0be9e04b62b104bf66a63bb05e4d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 12 Dec 2023 12:43:08 +0800 Subject: [PATCH 08/42] readd dotnet6.0 --- .../Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index 0c74a23204d4f..f1d894efb7f51 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -6,7 +6,7 @@ true - netstandard2.0 + netstandard2.0;net6.0 From a260de84f6f7adf99770df916eb751a1dcb9728e Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 12 Dec 2023 13:56:10 +0800 Subject: [PATCH 09/42] netcoreapp3.1 --- .../Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index f1d894efb7f51..1d15383239baf 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -6,7 +6,7 @@ true - netstandard2.0;net6.0 + netstandard2.0;netcoreapp3.1;net6.0 From b17c2771b19b82e31bb386783236a16dcfee48cd Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Dec 2023 16:13:53 +0800 Subject: [PATCH 10/42] validate package --- .../c-api-noopenmp-packaging-pipelines.yml | 32 ++++++++++++++----- tools/nuget/validate_package.py | 11 +++++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 91b9a12129793..b998dbc9921a1 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -865,13 +865,29 @@ stages: FolderPath: '$(Build.ArtifactStagingDirectory)' DoEsrp: ${{ parameters.DoEsrp }} - #- template: templates/validate-package.yml - # parameters: - # PackageType: 'nuget' - # PackagePath: '$(Build.ArtifactStagingDirectory)' - # PackageName: 'Microsoft.ML.OnnxRuntime.*nupkg' - # PlatformsSupported: 'win-x64,linux-x64' - # VerifyNugetSigning: false + - template: templates/validate-package.yml + parameters: + PackageType: 'nuget' + PackagePath: '$(Build.ArtifactStagingDirectory)' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.nupkg' + PlatformsSupported: 'win-x64,linux-x64' + VerifyNugetSigning: false + + - template: templates/validate-package.yml + parameters: + PackageType: 'nuget' + PackagePath: '$(Build.ArtifactStagingDirectory)' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-win.nupkg' + PlatformsSupported: 'win-x64' + VerifyNugetSigning: false + + - template: templates/validate-package.yml + parameters: + PackageType: 'nuget' + PackagePath: '$(Build.ArtifactStagingDirectory)' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-linux.nupkg' + PlatformsSupported: 'linux-x64' + VerifyNugetSigning: false - task: PublishPipelineArtifact@0 displayName: 'Publish Pipeline NuGet Artifact' @@ -1348,4 +1364,4 @@ stages: displayName: 'Publish Pipeline NuGet Artifact' inputs: artifactName: 'drop-signed-nuget-dml' - targetPath: '$(Build.ArtifactStagingDirectory)' \ No newline at end of file + targetPath: '$(Build.ArtifactStagingDirectory)' diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index daa96cc72e989..2312f691a1230 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -93,6 +93,7 @@ def check_if_headers_are_present(header_files, header_folder, file_list_in_packa raise Exception(header + " not found for " + platform) + def check_if_dlls_are_present( package_type, is_windows_ai_package, @@ -102,6 +103,7 @@ def check_if_dlls_are_present( platforms_supported, zip_file, package_path, + is_gpu_dependent_package = False, # only used for nuget packages ): platforms = platforms_supported.strip().split(",") if package_type == "tarball": @@ -128,13 +130,15 @@ def check_if_dlls_are_present( print("onnxruntime.dll not found for " + platform) raise Exception("onnxruntime.dll not found for " + platform) - if is_gpu_package: + if is_gpu_dependent_package: for dll in win_gpu_package_libraries: path = folder + "/" + dll print("Checking path: " + path) if path not in file_list_in_package: print(dll + " not found for " + platform) raise Exception(dll + " not found for " + platform) + + if is_gpu_package: check_if_headers_are_present(gpu_related_header_files, header_folder, file_list_in_package, platform) if is_dml_package: @@ -275,10 +279,12 @@ def validate_nuget(args): nuget_file_name = nuget_packages_found_in_path[0] full_nuget_path = os.path.join(args.package_path, nuget_file_name) - if "Gpu" in nuget_file_name: + if "Gpu" in nuget_file_name and "Gpu-" not in nuget_file_name: is_gpu_package = True + is_gpu_dependent_package = False else: is_gpu_package = False + is_gpu_dependent_package = True if "directml" in nuget_file_name.lower(): is_dml_package = True @@ -325,6 +331,7 @@ def validate_nuget(args): args.platforms_supported, zip_file, None, + is_gpu_dependent_package, ) verify_nuget_signing = args.verify_nuget_signing.lower() From 2549187e2463ecddb81deb6dfca498e89d91d549 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Dec 2023 16:41:30 +0800 Subject: [PATCH 11/42] validate package1 --- .../azure-pipelines/c-api-noopenmp-packaging-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index b998dbc9921a1..e216c54fd2891 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -869,7 +869,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.*nupkg' PlatformsSupported: 'win-x64,linux-x64' VerifyNugetSigning: false @@ -877,7 +877,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-win.nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-win.*nupkg' PlatformsSupported: 'win-x64' VerifyNugetSigning: false @@ -885,7 +885,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-linux.nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-linux.*nupkg' PlatformsSupported: 'linux-x64' VerifyNugetSigning: false From 42fe4bc3abc8c3b35a0fac3ddcf6170d0dead3dc Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Dec 2023 17:14:54 +0800 Subject: [PATCH 12/42] update --- .../azure-pipelines/c-api-noopenmp-packaging-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index e216c54fd2891..b2143b239922e 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -870,7 +870,6 @@ stages: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.*nupkg' - PlatformsSupported: 'win-x64,linux-x64' VerifyNugetSigning: false - template: templates/validate-package.yml From 315d1c7b3711d0268f821da4606ea6ed2e303bbb Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Dec 2023 20:10:15 +0800 Subject: [PATCH 13/42] update --- .../azure-pipelines/c-api-noopenmp-packaging-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index b2143b239922e..d8317b273792c 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -869,6 +869,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' + PlatformsSupported: '' PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.*nupkg' VerifyNugetSigning: false From 37ce9ca286c9adabeae28bd70d6f76ee287fb79d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Dec 2023 21:36:15 +0800 Subject: [PATCH 14/42] fix --- .vscode/settings.json | 2 +- .../c-api-noopenmp-packaging-pipelines.yml | 2 +- .../nuget/generate_nuspec_for_native_nuget.py | 2 +- tools/nuget/validate_package.py | 39 ++++++++++++------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2f2adc78f6de9..3e2b1f31dd6cf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,7 @@ // Auto sort imports "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.organizeImports": true + "source.organizeImports": "explicit" }, "editor.defaultFormatter": "ms-python.black-formatter" }, diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index d8317b273792c..027b485d5d91e 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -869,7 +869,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PlatformsSupported: '' + PlatformsSupported: 'win-x64,linux-x64' PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.*nupkg' VerifyNugetSigning: false diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 86854d3629200..d3905697df701 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -197,7 +197,7 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): - dependent_packages = True if package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" else False + dependent_packages = bool(package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux") if not dependent_packages: xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 2312f691a1230..bf38319944061 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -124,21 +124,25 @@ def check_if_dlls_are_present( folder = package_path + "/lib" header_folder = package_path + "/include" - path = folder + "/" + "onnxruntime.dll" - print("Checking path: " + path) - if path not in file_list_in_package: - print("onnxruntime.dll not found for " + platform) - raise Exception("onnxruntime.dll not found for " + platform) - - if is_gpu_dependent_package: + # In Nuget GPU package, onnxruntime.dll is in dependent package. + if not (package_type == "nuget" and is_gpu_package): + path = folder + "/" + "onnxruntime.dll" + print("Checking path: " + path) + if path not in file_list_in_package: + print("onnxruntime.dll not found for " + platform) + raise Exception("onnxruntime.dll not found for " + platform) + continue + + # In Nuget GPU package, cuda ep and tensorrt ep dlls are in dependent package. + if (is_gpu_package and package_type != "nuget") or is_gpu_dependent_package: for dll in win_gpu_package_libraries: path = folder + "/" + dll print("Checking path: " + path) if path not in file_list_in_package: print(dll + " not found for " + platform) raise Exception(dll + " not found for " + platform) - - if is_gpu_package: + # In Nuget GPU package, gpu header files are not in dependent package. + if (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package): check_if_headers_are_present(gpu_related_header_files, header_folder, file_list_in_package, platform) if is_dml_package: @@ -157,19 +161,24 @@ def check_if_dlls_are_present( folder = package_path + "/lib" header_folder = package_path + "/include" - path = folder + "/" + "libonnxruntime.so" - print("Checking path: " + path) - if path not in file_list_in_package: - print("libonnxruntime.so not found for " + platform) - raise Exception("libonnxruntime.so not found for " + platform) + # In Nuget GPU package, onnxruntime.dll is in dependent package. + if not (package_type == "nuget" and is_gpu_package): + path = folder + "/" + "libonnxruntime.so" + print("Checking path: " + path) + if path not in file_list_in_package: + print("libonnxruntime.so not found for " + platform) + raise Exception("libonnxruntime.so not found for " + platform) - if is_gpu_package: + # In Nuget GPU package, cuda ep and tensorrt ep dlls are in dependent package. + if (is_gpu_package and package_type != "nuget") or is_gpu_dependent_package: for so in linux_gpu_package_libraries: path = folder + "/" + so print("Checking path: " + path) if path not in file_list_in_package: print(so + " not found for " + platform) raise Exception(so + " not found for " + platform) + # In Nuget GPU package, gpu header files are not in dependent package. + if (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package): for header in gpu_related_header_files: path = header_folder + "/" + header print("Checking path: " + path) From d059354fcd87e8104c37804107e79b8e87ca0581 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 14 Dec 2023 22:11:34 +0800 Subject: [PATCH 15/42] add build_dir --- tools/nuget/validate_package.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index bf38319944061..9ee479bb4c795 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -119,7 +119,8 @@ def check_if_dlls_are_present( if package_type == "nuget": folder = "runtimes/" + platform + "/" + native_folder - header_folder = "build/native/include" + build_dir = "buildTransitive" if is_gpu_package else "build" + header_folder = f"{build_dir}/native/include" else: # zip package folder = package_path + "/lib" header_folder = package_path + "/include" @@ -156,7 +157,8 @@ def check_if_dlls_are_present( elif platform.startswith("linux"): if package_type == "nuget": folder = "runtimes/" + platform + "/native" - header_folder = "build/native/include" + build_dir = "buildTransitive" if is_gpu_package else "build" + header_folder = f"{build_dir}/native/include" else: # tarball package folder = package_path + "/lib" header_folder = package_path + "/include" From 93b24907f645ab97a78759b4d7ad013fdb7debe2 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 09:37:06 +0800 Subject: [PATCH 16/42] rm useless change --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e2b1f31dd6cf..ade4edbf07f10 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,7 @@ // Auto sort imports "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.organizeImports": "explicit" + "source.organizeImports": "true" }, "editor.defaultFormatter": "ms-python.black-formatter" }, From 332fce231eab12e3fe432d3dc7d6c54fbf209803 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 09:43:47 +0800 Subject: [PATCH 17/42] check gpu_dependent --- tools/nuget/validate_package.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 9ee479bb4c795..2dfab4e7f0c58 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -290,12 +290,12 @@ def validate_nuget(args): nuget_file_name = nuget_packages_found_in_path[0] full_nuget_path = os.path.join(args.package_path, nuget_file_name) - if "Gpu" in nuget_file_name and "Gpu-" not in nuget_file_name: - is_gpu_package = True - is_gpu_dependent_package = False + if "Gpu" in nuget_file_name: + is_gpu_package = bool("Gpu-" not in nuget_file_name) + is_gpu_dependent_package = bool("Gpu-" in nuget_file_name) else: is_gpu_package = False - is_gpu_dependent_package = True + is_gpu_dependent_package = False if "directml" in nuget_file_name.lower(): is_dml_package = True From 168c8b7dd97e04c2dd46f6ec1c31484daa5f9143 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 10:16:54 +0800 Subject: [PATCH 18/42] lint runner --- .../nuget/generate_nuspec_for_native_nuget.py | 33 +++++++++++++++---- tools/nuget/validate_package.py | 11 ++++--- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index d3905697df701..bf8a473ca8dc6 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -60,7 +60,11 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] - if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu-linux": + if ( + child_file.suffix in suffixes + and is_this_file_needed(ep, child_file.name, package_name) + and package_name != "Microsoft.ML.OnnxRuntime.Gpu-linux" + ): files_list.append( '' % cpu_arch ) @@ -86,7 +90,11 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu-win": + if ( + child_file.suffix == ".so" + and is_this_file_needed(ep, child_file.name, package_name) + and package_name != "Microsoft.ML.OnnxRuntime.Gpu-win" + ): files_list.append( '' % cpu_arch ) @@ -197,13 +205,16 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): - dependent_packages = bool(package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux") + dependent_packages = bool( + package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" + ) if not dependent_packages: xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": xml_text.append('') xml_text.append('') + def generate_dependencies(xml_text, package_name, version): dml_dependency = '' @@ -409,19 +420,25 @@ def generate_files(line_list, args): "' + + '" target="' + + include_dir + + '" />' ) files_list.append( "' + + '" target="' + + include_dir + + '" />' ) files_list.append( "' + + '" target="' + + include_dir + + '" />' ) if is_training_package: @@ -554,7 +571,9 @@ def generate_files(line_list, args): else: ep_list = [None] for ep in ep_list: - generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package, args.package_name) + generate_file_list_for_ep( + nuget_artifacts_dir, ep, files_list, include_pdbs, is_training_package, args.package_name + ) is_ado_packaging_build = True else: # Code path for local dev build diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 2dfab4e7f0c58..ab7c8e9f44855 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -93,7 +93,6 @@ def check_if_headers_are_present(header_files, header_folder, file_list_in_packa raise Exception(header + " not found for " + platform) - def check_if_dlls_are_present( package_type, is_windows_ai_package, @@ -103,7 +102,7 @@ def check_if_dlls_are_present( platforms_supported, zip_file, package_path, - is_gpu_dependent_package = False, # only used for nuget packages + is_gpu_dependent_package=False, # only used for nuget packages ): platforms = platforms_supported.strip().split(",") if package_type == "tarball": @@ -143,7 +142,9 @@ def check_if_dlls_are_present( print(dll + " not found for " + platform) raise Exception(dll + " not found for " + platform) # In Nuget GPU package, gpu header files are not in dependent package. - if (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package): + if (is_gpu_package and package_type != "nuget") or ( + package_type == "nuget" and not is_gpu_dependent_package + ): check_if_headers_are_present(gpu_related_header_files, header_folder, file_list_in_package, platform) if is_dml_package: @@ -180,7 +181,9 @@ def check_if_dlls_are_present( print(so + " not found for " + platform) raise Exception(so + " not found for " + platform) # In Nuget GPU package, gpu header files are not in dependent package. - if (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package): + if (is_gpu_package and package_type != "nuget") or ( + package_type == "nuget" and not is_gpu_dependent_package + ): for header in gpu_related_header_files: path = header_folder + "/" + header print("Checking path: " + path) From 6deb08a7b581142f02e7d9790db1297a16388f58 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 10:18:35 +0800 Subject: [PATCH 19/42] update --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ade4edbf07f10..2f2adc78f6de9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,7 @@ // Auto sort imports "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.organizeImports": "true" + "source.organizeImports": true }, "editor.defaultFormatter": "ms-python.black-formatter" }, From b1607b311df250ce05f3cbbb0746f885bdcf79f3 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 16:28:12 +0800 Subject: [PATCH 20/42] flex download --- .../azure-pipelines/nuget/templates/test_win.yml | 14 +++++++++----- .../github/azure-pipelines/templates/c-api-cpu.yml | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) 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 a15c3061913f8..18006daf403e4 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 @@ -9,6 +9,8 @@ parameters: TestDataArtifactSuffix: '' Skipx86Tests: 'false' CudaVersion: '' + SpecificArtifact: false + BuildId: '' stages: - stage: NuGet_Test_Win_${{ parameters.StageSuffix }} @@ -58,11 +60,13 @@ stages: arguments: 'amd64' modifyEnvironment: true - - task: DownloadPipelineArtifact@0 - displayName: 'Download Pipeline Artifact' - inputs: - artifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }} - targetPath: '$(Build.BinariesDirectory)\nuget-artifact' + - template: ../../templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact' + ArtifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }} + TargetPath: '$(Build.BinariesDirectory)\nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - template: get-nuget-package-version-as-variable.yml parameters: diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index fff75e62716f5..37b4bdc43afcd 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -779,6 +779,8 @@ stages: Skipx86Tests : false NugetPackageName : 'Microsoft.ML.OnnxRuntime' ArtifactSuffix: 'CPU' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - template: ../nuget/templates/test_linux.yml parameters: From 05565cb5492a7d3f38ddc9bdced5e79864de88b4 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 16:52:20 +0800 Subject: [PATCH 21/42] update --- .../azure-pipelines/c-api-noopenmp-packaging-pipelines.yml | 2 ++ .../ci_build/github/azure-pipelines/cuda-packaging-pipeline.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 3591bb3314851..53d5d00b00500 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -1147,6 +1147,8 @@ stages: ArtifactSuffix: 'GPU' StageSuffix: 'GPU' Skipx86Tests: 'true' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - template: nuget/templates/test_linux.yml parameters: diff --git a/tools/ci_build/github/azure-pipelines/cuda-packaging-pipeline.yml b/tools/ci_build/github/azure-pipelines/cuda-packaging-pipeline.yml index 8a9592282cd46..efb936a8ded3d 100644 --- a/tools/ci_build/github/azure-pipelines/cuda-packaging-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/cuda-packaging-pipeline.yml @@ -160,6 +160,8 @@ stages: StageSuffix: 'GPU' Skipx86Tests: 'true' CudaVersion: ${{ parameters.CudaVersion }} + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} ## Linux GPU Testing - template: nuget/templates/test_linux.yml parameters: From ce9972825cc752ac93589293c688f7dcea0be6e2 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 15 Dec 2023 22:00:06 +0800 Subject: [PATCH 22/42] update props.xml --- .../targets/netstandard/props.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/targets/netstandard/props.xml b/csharp/src/Microsoft.ML.OnnxRuntime/targets/netstandard/props.xml index 9376d98c040a9..efe5c659f250a 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/targets/netstandard/props.xml +++ b/csharp/src/Microsoft.ML.OnnxRuntime/targets/netstandard/props.xml @@ -37,7 +37,7 @@ x86 arm64 - arm + arm $(Platform) @@ -55,7 +55,8 @@ + Condition="('$(PlatformTarget)' == 'x64' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' != 'true')) AND + Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-x64\native\onnxruntime.dll')"> onnxruntime.dll PreserveNewest false @@ -146,8 +147,8 @@ PreserveNewest false - - + + onnxruntime.dll From 87cf991e2cdb9182da9bb882b379c3e53a6c91ea Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Sat, 16 Dec 2023 18:42:35 +0800 Subject: [PATCH 23/42] update Onnxrunitme.CSharp.proj --- csharp/OnnxRuntime.CSharp.proj | 13 ++++++++----- .../c-api-noopenmp-packaging-pipelines.yml | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index 5e43756ced7b1..f58798f8362bd 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -20,6 +20,7 @@ CMake creates a target to this project true true None + false true @@ -81,8 +82,10 @@ CMake creates a target to this project - $([System.DateTime]::UtcNow.ToString(yyyyMMdd)) - $([System.DateTime]::UtcNow.ToString(hhmm)) + + + $([System.DateTime]::UtcNow.ToString(yyyyMMdd)) + $([System.DateTime]::UtcNow.ToString(hhmm)) @(MajorVersionNumber) $(PackageVersion)$(ReleaseVersionSuffix) $(PackageVersion) @@ -100,10 +103,10 @@ CMake creates a target to this project - - + + Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId);IncludeMobileTargets=$(IncludeMobileTargets)"/> diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 53d5d00b00500..2ad361c6ed1c1 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -706,6 +706,8 @@ stages: variables: breakCodesignValidationInjection: ${{ parameters.DoEsrp }} ReleaseVersionSuffix: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']] + CurrentDate: $[format('{0:yyyyMMdd}', pipeline.startTime)] + CurrentTime: $[format('{0:HHmm}', pipeline.startTime)] steps: - checkout: self @@ -813,6 +815,10 @@ stages: platform: 'Any CPU' msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' + env: + # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables + CurrentDate: $(CurrentDate) + CurrentTime: $(CurrentTime) - task: MSBuild@1 displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu-win' @@ -822,6 +828,11 @@ stages: platform: 'Any CPU' msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-win -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' + env: + # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables + CurrentDate: $(CurrentDate) + CurrentTime: $(CurrentTime) + IsDependentPackage: 'True' - task: MSBuild@1 displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu-linux' @@ -831,6 +842,11 @@ stages: platform: 'Any CPU' msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' + env: + # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables + CurrentDate: $(CurrentDate) + CurrentTime: $(CurrentTime) + IsDependentPackage: 'True' - task: BatchScript@1 displayName: 'Add TensorRT header file to the native nuGet package' From 4ef86548f2f69398becfbfb4ff3a8d8d414bb700 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 19 Dec 2023 09:18:53 +0800 Subject: [PATCH 24/42] rename as comments --- csharp/OnnxRuntime.CSharp.proj | 6 +++--- .../c-api-noopenmp-packaging-pipelines.yml | 16 +++++++------- .../nuget/generate_nuspec_for_native_nuget.py | 21 ++++++++++--------- tools/nuget/validate_package.py | 4 ++-- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index f58798f8362bd..a46e8289f59b0 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -20,7 +20,7 @@ CMake creates a target to this project true true None - false + false true @@ -103,8 +103,8 @@ CMake creates a target to this project - - + diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 1a23e77a20d4c..acf08ec003848 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -823,32 +823,32 @@ stages: CurrentTime: $(CurrentTime) - task: MSBuild@1 - displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu-win' + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-win -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' env: # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables CurrentDate: $(CurrentDate) CurrentTime: $(CurrentTime) - IsDependentPackage: 'True' + IsPlatformSpecificSubPackage: 'True' - task: MSBuild@1 - displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu-linux' + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu-linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' env: # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables CurrentDate: $(CurrentDate) CurrentTime: $(CurrentTime) - IsDependentPackage: 'True' + IsPlatformSpecificSubPackage: 'True' - task: BatchScript@1 displayName: 'Add TensorRT header file to the native nuGet package' @@ -895,7 +895,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-win.*nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows.*nupkg' PlatformsSupported: 'win-x64' VerifyNugetSigning: false @@ -903,7 +903,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu-linux.*nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux.*nupkg' PlatformsSupported: 'linux-x64' VerifyNugetSigning: false diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index bf8a473ca8dc6..e895f48c0019e 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -39,7 +39,8 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # Currently we take onnxruntime_providers_cuda from CUDA build # And onnxruntime, onnxruntime_providers_shared and # onnxruntime_providers_tensorrt from tensorrt build -# cuda binaries are in dependent packages not in Microst.ML.OnnxRuntime.Gpu +# cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.Gpu.Sub.{Linux|Windows} +# and not included in the base Microsoft.ML.OnnxRuntime.Gpu package def is_this_file_needed(ep, filename, package_name): if package_name == "Microsoft.ML.OnnxRuntime.Gpu": return False @@ -63,7 +64,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, if ( child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) - and package_name != "Microsoft.ML.OnnxRuntime.Gpu-linux" + and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux" ): files_list.append( '' % cpu_arch @@ -93,7 +94,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, if ( child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) - and package_name != "Microsoft.ML.OnnxRuntime.Gpu-win" + and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows" ): files_list.append( '' % cpu_arch @@ -206,13 +207,13 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): dependent_packages = bool( - package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" or package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" + package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows" or package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux" ) if not dependent_packages: xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": - xml_text.append('') - xml_text.append('') + xml_text.append('') + xml_text.append('') def generate_dependencies(xml_text, package_name, version): @@ -347,8 +348,8 @@ def generate_files(line_list, args): ] is_mklml_package = args.package_name == "Microsoft.ML.OnnxRuntime.MKLML" is_cuda_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu" - is_cuda_gpu_win_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-win" - is_cuda_gpu_linux_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu-linux" + is_cuda_gpu_win_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows" + is_cuda_gpu_linux_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux" is_rocm_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.ROCm" is_dml_package = args.package_name == "Microsoft.ML.OnnxRuntime.DirectML" is_windowsai_package = args.package_name == "Microsoft.AI.MachineLearning" @@ -564,7 +565,7 @@ def generate_files(line_list, args): if nuget_artifacts_dir.exists(): # Code path for ADO build pipeline, the files under 'nuget-artifacts' are # downloaded from other build jobs - if is_cuda_gpu_package or is_cuda_gpu_win_package or is_cuda_gpu_linux_package: + if is_cuda_gpu_package or is_cuda_gpu_win_sub_package or is_cuda_gpu_linux_sub_package: ep_list = ["tensorrt", "cuda", None] elif is_rocm_gpu_package: ep_list = ["rocm", None] @@ -767,7 +768,7 @@ def generate_files(line_list, args): + '\\native" />' ) - if args.execution_provider == "cuda" or is_cuda_gpu_win_package and not is_ado_packaging_build: + if args.execution_provider == "cuda" or is_cuda_gpu_win_sub_package and not is_ado_packaging_build: files_list.append( " Date: Tue, 19 Dec 2023 10:13:19 +0800 Subject: [PATCH 25/42] rename 2 --- .../c-api-noopenmp-packaging-pipelines.yml | 12 ++++++------ tools/nuget/generate_nuspec_for_native_nuget.py | 16 ++++++++-------- tools/nuget/validate_package.py | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index acf08ec003848..f61596d777ed3 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -823,12 +823,12 @@ stages: CurrentTime: $(CurrentTime) - task: MSBuild@1 - displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows' + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' env: # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables @@ -837,12 +837,12 @@ stages: IsPlatformSpecificSubPackage: 'True' - task: MSBuild@1 - displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux' + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' env: # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables @@ -895,7 +895,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows.*nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows.*nupkg' PlatformsSupported: 'win-x64' VerifyNugetSigning: false @@ -903,7 +903,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux.*nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux.*nupkg' PlatformsSupported: 'linux-x64' VerifyNugetSigning: false diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index e895f48c0019e..b74d27875042a 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -39,7 +39,7 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # Currently we take onnxruntime_providers_cuda from CUDA build # And onnxruntime, onnxruntime_providers_shared and # onnxruntime_providers_tensorrt from tensorrt build -# cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.Gpu.Sub.{Linux|Windows} +# cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.Sub.Gpu{Linux|Windows} # and not included in the base Microsoft.ML.OnnxRuntime.Gpu package def is_this_file_needed(ep, filename, package_name): if package_name == "Microsoft.ML.OnnxRuntime.Gpu": @@ -64,7 +64,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, if ( child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) - and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux" + and package_name != "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" ): files_list.append( '' % cpu_arch @@ -94,7 +94,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, if ( child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) - and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows" + and package_name != "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" ): files_list.append( '' % cpu_arch @@ -207,13 +207,13 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): dependent_packages = bool( - package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows" or package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux" + package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" or package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" ) if not dependent_packages: xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": - xml_text.append('') - xml_text.append('') + xml_text.append('') + xml_text.append('') def generate_dependencies(xml_text, package_name, version): @@ -348,8 +348,8 @@ def generate_files(line_list, args): ] is_mklml_package = args.package_name == "Microsoft.ML.OnnxRuntime.MKLML" is_cuda_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu" - is_cuda_gpu_win_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Windows" - is_cuda_gpu_linux_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu.Sub.Linux" + is_cuda_gpu_win_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" + is_cuda_gpu_linux_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" is_rocm_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.ROCm" is_dml_package = args.package_name == "Microsoft.ML.OnnxRuntime.DirectML" is_windowsai_package = args.package_name == "Microsoft.AI.MachineLearning" diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 489e94e7d0cc1..9ddeaf1aaf017 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -294,7 +294,7 @@ def validate_nuget(args): full_nuget_path = os.path.join(args.package_path, nuget_file_name) if "Gpu" in nuget_file_name: - is_gpu_package = bool("Gpu.Sub" not in nuget_file_name) + is_gpu_package = bool("Sub.Gpu" not in nuget_file_name) is_gpu_dependent_package = not is_gpu_package else: is_gpu_package = False From 7e9071c9b8f4bab0281237084e526d3fa89d35f1 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 19 Dec 2023 11:53:30 +0800 Subject: [PATCH 26/42] headers --- .../c-api-noopenmp-packaging-pipelines.yml | 24 ++------- .../nuget/generate_nuspec_for_native_nuget.py | 53 ++++++++++--------- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index f61596d777ed3..c0ccade3388d5 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -708,8 +708,8 @@ stages: variables: breakCodesignValidationInjection: ${{ parameters.DoEsrp }} ReleaseVersionSuffix: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']] - CurrentDate: $[format('{0:yyyyMMdd}', pipeline.startTime)] - CurrentTime: $[format('{0:HHmm}', pipeline.startTime)] + BuildDate: $[format('{0:yyyyMMdd}', pipeline.startTime)] + BuildTime: $[format('{0:HHmm}', pipeline.startTime)] steps: - checkout: self @@ -815,12 +815,8 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - env: - # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables - CurrentDate: $(CurrentDate) - CurrentTime: $(CurrentTime) - task: MSBuild@1 displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows' @@ -828,13 +824,8 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime) -p:IsPlatformSpecificSubPackage=True' workingDirectory: '$(Build.SourcesDirectory)\csharp' - env: - # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables - CurrentDate: $(CurrentDate) - CurrentTime: $(CurrentTime) - IsPlatformSpecificSubPackage: 'True' - task: MSBuild@1 displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux' @@ -842,13 +833,8 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime) -p:IsPlatformSpecificSubPackage=True' workingDirectory: '$(Build.SourcesDirectory)\csharp' - env: - # check out csharp/OnnxRuntime.CSharp.proj for the usage of these variables - CurrentDate: $(CurrentDate) - CurrentTime: $(CurrentTime) - IsPlatformSpecificSubPackage: 'True' - task: BatchScript@1 displayName: 'Add TensorRT header file to the native nuGet package' diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index b74d27875042a..c4a6efd8e42c2 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -415,32 +415,35 @@ def generate_files(line_list, args): runtimes = f'{runtimes_target}{args.target_architecture}\\{runtimes_native_folder}"' # Process headers - build_dir = "buildTransitive" if "Microsoft.ML.OnnxRuntime.Gpu" in args.package_name else "build" + build_dir = "buildTransitive" if "Gpu" in args.package_name else "build" include_dir = f"{build_dir}\\native\\include" - files_list.append( - "' - ) - files_list.append( - "' - ) - files_list.append( - "' - ) + + # Sub.Gpu packages do not include the onnxruntime headers + if not "Sub.Gpu" in args.package_name: + files_list.append( + "' + ) + files_list.append( + "' + ) + files_list.append( + "' + ) if is_training_package: files_list.append( From 4a5c10f84e3e62805ca5b10ba332e5ab652d1fe3 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 19 Dec 2023 15:57:10 +0800 Subject: [PATCH 27/42] lint --- tools/nuget/generate_nuspec_for_native_nuget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index c4a6efd8e42c2..13a7f061b905c 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -419,7 +419,7 @@ def generate_files(line_list, args): include_dir = f"{build_dir}\\native\\include" # Sub.Gpu packages do not include the onnxruntime headers - if not "Sub.Gpu" in args.package_name: + if "Sub.Gpu" not in args.package_name: files_list.append( " Date: Tue, 19 Dec 2023 15:57:43 +0800 Subject: [PATCH 28/42] generate sub package in one proj file --- csharp/OnnxRuntime.CSharp.proj | 81 +++++++++++++++++++ .../c-api-noopenmp-packaging-pipelines.yml | 22 +---- 2 files changed, 82 insertions(+), 21 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index a46e8289f59b0..ecd638ac55171 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -147,6 +147,87 @@ CMake creates a target to this project /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index c0ccade3388d5..ad7853ee4784d 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -708,8 +708,6 @@ stages: variables: breakCodesignValidationInjection: ${{ parameters.DoEsrp }} ReleaseVersionSuffix: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']] - BuildDate: $[format('{0:yyyyMMdd}', pipeline.startTime)] - BuildTime: $[format('{0:HHmm}', pipeline.startTime)] steps: - checkout: self @@ -815,25 +813,7 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime)' - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - - task: MSBuild@1 - displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows' - inputs: - solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' - configuration: RelWithDebInfo - platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime) -p:IsPlatformSpecificSubPackage=True' - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - - task: MSBuild@1 - displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux' - inputs: - solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' - configuration: RelWithDebInfo - platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime) -p:IsPlatformSpecificSubPackage=True' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: BatchScript@1 From 92058512f2d9f8c980a1658acbeefc359548533d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 19 Dec 2023 16:33:47 +0800 Subject: [PATCH 29/42] some refactor --- .../nuget/generate_nuspec_for_native_nuget.py | 26 +++++++--------- tools/nuget/validate_package.py | 31 ++++++++++--------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 13a7f061b905c..3451542b57e95 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -41,9 +41,15 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # onnxruntime_providers_tensorrt from tensorrt build # cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.Sub.Gpu{Linux|Windows} # and not included in the base Microsoft.ML.OnnxRuntime.Gpu package -def is_this_file_needed(ep, filename, package_name): +def is_this_file_needed(ep, file, package_name): + filename = file.name + suffix = file.suffix if package_name == "Microsoft.ML.OnnxRuntime.Gpu": return False + if package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" and suffix in [".dll", ".lib", "pdb"]: + return False + if package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" and suffix == ".so": + return False return (ep != "cuda" or "cuda" in filename) and (ep != "tensorrt" or "cuda" not in filename) @@ -60,12 +66,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, if child.name == get_package_name("win", cpu_arch, ep, is_training_package): child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): - suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] - if ( - child_file.suffix in suffixes - and is_this_file_needed(ep, child_file.name, package_name) - and package_name != "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" - ): + if is_this_file_needed(ep, child_file, package_name): files_list.append( '' % cpu_arch ) @@ -91,11 +92,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if ( - child_file.suffix == ".so" - and is_this_file_needed(ep, child_file.name, package_name) - and package_name != "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" - ): + if is_this_file_needed(ep, child_file, package_name): files_list.append( '' % cpu_arch ) @@ -207,7 +204,8 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): dependent_packages = bool( - package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" or package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" + package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" + or package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" ) if not dependent_packages: xml_text.append('') @@ -937,7 +935,7 @@ def generate_files(line_list, args): os.system(copy_command + " " + source_targets + " " + target_targets) files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') + files_list.append("') files_list.append("') # Process xamarin targets files diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 9ddeaf1aaf017..5796b9e0a9956 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -112,6 +112,14 @@ def check_if_dlls_are_present( else: file_list_in_package = zip_file.namelist() + # In Nuget GPU package, onnxruntime.dll is in dependent package. + package_contains_library = not bool(package_type == "nuget" and is_gpu_package) + # In Nuget GPU package, gpu header files are not in dependent package. + package_contains_headers = bool( + (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package) + ) + # In Nuget GPU package, cuda ep and tensorrt ep dlls are in dependent package + package_contains_cuda_binaries = bool((is_gpu_package and package_type != "nuget") or is_gpu_dependent_package) for platform in platforms: if platform.startswith("win"): native_folder = "_native" if is_windows_ai_package else "native" @@ -125,7 +133,7 @@ def check_if_dlls_are_present( header_folder = package_path + "/include" # In Nuget GPU package, onnxruntime.dll is in dependent package. - if not (package_type == "nuget" and is_gpu_package): + if package_contains_library: path = folder + "/" + "onnxruntime.dll" print("Checking path: " + path) if path not in file_list_in_package: @@ -133,18 +141,15 @@ def check_if_dlls_are_present( raise Exception("onnxruntime.dll not found for " + platform) continue - # In Nuget GPU package, cuda ep and tensorrt ep dlls are in dependent package. - if (is_gpu_package and package_type != "nuget") or is_gpu_dependent_package: + if package_contains_cuda_binaries: for dll in win_gpu_package_libraries: path = folder + "/" + dll print("Checking path: " + path) if path not in file_list_in_package: print(dll + " not found for " + platform) raise Exception(dll + " not found for " + platform) - # In Nuget GPU package, gpu header files are not in dependent package. - if (is_gpu_package and package_type != "nuget") or ( - package_type == "nuget" and not is_gpu_dependent_package - ): + + if package_contains_headers: check_if_headers_are_present(gpu_related_header_files, header_folder, file_list_in_package, platform) if is_dml_package: @@ -164,26 +169,22 @@ def check_if_dlls_are_present( folder = package_path + "/lib" header_folder = package_path + "/include" - # In Nuget GPU package, onnxruntime.dll is in dependent package. - if not (package_type == "nuget" and is_gpu_package): + if package_contains_library: path = folder + "/" + "libonnxruntime.so" print("Checking path: " + path) if path not in file_list_in_package: print("libonnxruntime.so not found for " + platform) raise Exception("libonnxruntime.so not found for " + platform) - # In Nuget GPU package, cuda ep and tensorrt ep dlls are in dependent package. - if (is_gpu_package and package_type != "nuget") or is_gpu_dependent_package: + if package_contains_cuda_binaries: for so in linux_gpu_package_libraries: path = folder + "/" + so print("Checking path: " + path) if path not in file_list_in_package: print(so + " not found for " + platform) raise Exception(so + " not found for " + platform) - # In Nuget GPU package, gpu header files are not in dependent package. - if (is_gpu_package and package_type != "nuget") or ( - package_type == "nuget" and not is_gpu_dependent_package - ): + + if package_contains_headers: for header in gpu_related_header_files: path = header_folder + "/" + header print("Checking path: " + path) From aebb1d43f7db5486dba4c70b5f28ffd86d91ba1b Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 20 Dec 2023 19:47:58 +0800 Subject: [PATCH 30/42] refact csproj --- csharp/OnnxRuntime.CSharp.proj | 113 ++++-------------- .../c-api-noopenmp-packaging-pipelines.yml | 7 +- .../nuget/generate_nuspec_for_native_nuget.py | 25 ++-- tools/nuget/validate_package.py | 8 +- 4 files changed, 43 insertions(+), 110 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index ecd638ac55171..5abeacc17a931 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -21,6 +21,7 @@ CMake creates a target to this project true None false + NativeNuget.nuspec true @@ -59,7 +60,7 @@ CMake creates a target to this project - + @@ -94,23 +95,10 @@ CMake creates a target to this project - - - - - - - - - - + - @@ -119,7 +107,7 @@ CMake creates a target to this project @@ -147,85 +135,32 @@ CMake creates a target to this project /> - - - - - + + + - - - - - - - - - - + + + - - + - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index ad7853ee4784d..8b1bd571fd3da 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -854,14 +854,15 @@ stages: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' PlatformsSupported: 'win-x64,linux-x64' - PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.*nupkg' + # 1* stands for version number. we use it to fileter Gpu.Windows and Gpu.Linux packages + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.1*nupkg' VerifyNugetSigning: false - template: templates/validate-package.yml parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows.*nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Windows.*nupkg' PlatformsSupported: 'win-x64' VerifyNugetSigning: false @@ -869,7 +870,7 @@ stages: parameters: PackageType: 'nuget' PackagePath: '$(Build.ArtifactStagingDirectory)' - PackageName: 'Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux.*nupkg' + PackageName: 'Microsoft.ML.OnnxRuntime.Gpu.Linux.*nupkg' PlatformsSupported: 'linux-x64' VerifyNugetSigning: false diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 3451542b57e95..42f2903ca8533 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -39,16 +39,16 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # Currently we take onnxruntime_providers_cuda from CUDA build # And onnxruntime, onnxruntime_providers_shared and # onnxruntime_providers_tensorrt from tensorrt build -# cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.Sub.Gpu{Linux|Windows} +# cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.{Linux|Windows} # and not included in the base Microsoft.ML.OnnxRuntime.Gpu package def is_this_file_needed(ep, file, package_name): filename = file.name suffix = file.suffix if package_name == "Microsoft.ML.OnnxRuntime.Gpu": return False - if package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" and suffix in [".dll", ".lib", "pdb"]: + if package_name == "Microsoft.ML.OnnxRuntime.Gpu.Linux" and suffix in [".dll", ".lib", "pdb"]: return False - if package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" and suffix == ".so": + if package_name == "Microsoft.ML.OnnxRuntime.Gpu.Windows" and suffix == ".so": return False return (ep != "cuda" or "cuda" in filename) and (ep != "tensorrt" or "cuda" not in filename) @@ -137,6 +137,7 @@ def parse_arguments(): help="The selected execution provider for this build.", ) parser.add_argument("--sdk_info", required=False, default="", type=str, help="dependency SDK information.") + parser.add_argument("--nuspec_name", required=False, default="NativeNuget.nuspec", type=str, help="nuget spec name.") return parser.parse_args() @@ -204,14 +205,14 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): dependent_packages = bool( - package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" - or package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" + package_name == "Microsoft.ML.OnnxRuntime.Gpu.Windows" + or package_name == "Microsoft.ML.OnnxRuntime.Gpu.Linux" ) if not dependent_packages: xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": - xml_text.append('') - xml_text.append('') + xml_text.append('') + xml_text.append('') def generate_dependencies(xml_text, package_name, version): @@ -346,8 +347,8 @@ def generate_files(line_list, args): ] is_mklml_package = args.package_name == "Microsoft.ML.OnnxRuntime.MKLML" is_cuda_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu" - is_cuda_gpu_win_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Windows" - is_cuda_gpu_linux_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Sub.Gpu.Linux" + is_cuda_gpu_win_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu.Windows" + is_cuda_gpu_linux_sub_package = args.package_name == "Microsoft.ML.OnnxRuntime.Gpu.Linux" is_rocm_gpu_package = args.package_name == "Microsoft.ML.OnnxRuntime.ROCm" is_dml_package = args.package_name == "Microsoft.ML.OnnxRuntime.DirectML" is_windowsai_package = args.package_name == "Microsoft.AI.MachineLearning" @@ -417,7 +418,7 @@ def generate_files(line_list, args): include_dir = f"{build_dir}\\native\\include" # Sub.Gpu packages do not include the onnxruntime headers - if "Sub.Gpu" not in args.package_name: + if args.package_name != "Microsoft.ML.OnnxRuntime.Gpu": files_list.append( "" ) - else: files_list.append( " Date: Wed, 20 Dec 2023 22:50:37 +0800 Subject: [PATCH 31/42] make GPU.windows and GPU.linux can work --- csharp/OnnxRuntime.CSharp.proj | 11 ++-- .../nuget/generate_nuspec_for_native_nuget.py | 59 +++++++++---------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index 5abeacc17a931..6a8dcb4378c21 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -47,6 +47,13 @@ CMake creates a target to this project python + + + + $([System.DateTime]::UtcNow.ToString(yyyyMMdd)) + $([System.DateTime]::UtcNow.ToString(hhmm)) + + @@ -83,10 +90,6 @@ CMake creates a target to this project - - - $([System.DateTime]::UtcNow.ToString(yyyyMMdd)) - $([System.DateTime]::UtcNow.ToString(hhmm)) @(MajorVersionNumber) $(PackageVersion)$(ReleaseVersionSuffix) $(PackageVersion) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 42f2903ca8533..675605be7ec22 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -41,18 +41,11 @@ def get_package_name(os, cpu_arch, ep, is_training_package): # onnxruntime_providers_tensorrt from tensorrt build # cuda binaries are split out into the platform dependent packages Microsoft.ML.OnnxRuntime.{Linux|Windows} # and not included in the base Microsoft.ML.OnnxRuntime.Gpu package -def is_this_file_needed(ep, file, package_name): - filename = file.name - suffix = file.suffix +def is_this_file_needed(ep, filename, package_name): if package_name == "Microsoft.ML.OnnxRuntime.Gpu": return False - if package_name == "Microsoft.ML.OnnxRuntime.Gpu.Linux" and suffix in [".dll", ".lib", "pdb"]: - return False - if package_name == "Microsoft.ML.OnnxRuntime.Gpu.Windows" and suffix == ".so": - return False return (ep != "cuda" or "cuda" in filename) and (ep != "tensorrt" or "cuda" not in filename) - # nuget_artifacts_dir: the directory with uncompressed C API tarball/zip files # ep: cuda, tensorrt, None # files_list: a list of xml string pieces to append @@ -66,7 +59,8 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, if child.name == get_package_name("win", cpu_arch, ep, is_training_package): child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): - if is_this_file_needed(ep, child_file, package_name): + suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] + if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Linux": files_list.append( '' % cpu_arch ) @@ -92,7 +86,7 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if is_this_file_needed(ep, child_file, package_name): + if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Windows": files_list.append( '' % cpu_arch ) @@ -204,12 +198,7 @@ def generate_repo_url(line_list, repo_url, commit_id): def add_common_dependencies(xml_text, package_name, version): - dependent_packages = bool( - package_name == "Microsoft.ML.OnnxRuntime.Gpu.Windows" - or package_name == "Microsoft.ML.OnnxRuntime.Gpu.Linux" - ) - if not dependent_packages: - xml_text.append('') + xml_text.append('') if package_name == "Microsoft.ML.OnnxRuntime.Gpu": xml_text.append('') xml_text.append('') @@ -580,25 +569,29 @@ def generate_files(line_list, args): is_ado_packaging_build = True else: # Code path for local dev build - files_list.append( - "" - ) - files_list.append( - "" - ) - if include_pdbs and os.path.exists(os.path.join(args.native_build_path, "onnxruntime.pdb")): + # for local dev build, gpu linux package is also generated for compatibility though it is not used + if not is_cuda_gpu_linux_sub_package: + files_list.append( + "" + ) files_list.append( - "" + "" ) + if include_pdbs and os.path.exists(os.path.join(args.native_build_path, "onnxruntime.pdb")): + files_list.append( + "" + ) else: - files_list.append( - "' - ) + ort_so = os.path.join(args.native_build_path, "libonnxruntime.so") + if os.path.exists(ort_so): + files_list.append( + "' + ) if includes_winml: # Process microsoft.ai.machinelearning import lib, dll, and pdb @@ -894,6 +887,8 @@ def generate_files(line_list, args): if ( is_cpu_package or is_cuda_gpu_package + or is_cuda_gpu_linux_sub_package + or is_cuda_gpu_win_sub_package or is_rocm_gpu_package or is_dml_package or is_mklml_package From a4d288669b6b5873490f47bdcc60c7849aaac2db Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 20 Dec 2023 23:20:14 +0800 Subject: [PATCH 32/42] minor fix --- tools/nuget/generate_nuspec_for_native_nuget.py | 13 ++++++++++++- tools/nuget/validate_package.py | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 675605be7ec22..212d6a0313f7d 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -169,7 +169,18 @@ def generate_description(line_list, package_name): description = ( "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." ) - + elif "Microsoft.ML.OnnxRuntime.Gpu.Linux" in package_name: + description = ( + "This package contains Linux native shared library artifacts for ONNX Runtime with CUDA." + ) + elif "Microsoft.ML.OnnxRuntime.Gpu.Windows" in package_name: + description = ( + "This package contains Windows native shared library artifacts for ONNX Runtime with CUDA." + ) + elif "Microsoft.ML.OnnxRuntime.Gpu.1" in package_name: # This is a Microsoft.ML.OnnxRuntime.GPU.* package, 1 is begin of version, that is used to filter Gpu.Windows/Gpu.linux + description = ( + "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." + ) line_list.append("" + description + "") diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 3107728ab0630..50ad2deaecff7 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -294,8 +294,8 @@ def validate_nuget(args): nuget_file_name = nuget_packages_found_in_path[0] full_nuget_path = os.path.join(args.package_path, nuget_file_name) - is_gpu_package = bool(args.package_name.lower().contains("microsoft.ml.onnxruntime.gpu.1")) - is_gpu_dependent_package = bool(args.package_name.lower().contains("microsoft.ml.onnxruntime.gpu.windows") or args.package_name.lower().contains("microsoft.ml.onnnxruntime.linux")) + is_gpu_package = bool("microsoft.ml.onnxruntime.gpu.1" in args.package_name.lower()) + is_gpu_dependent_package = bool("microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() or "microsoft.ml.onnnxruntime.linux" in args.package_name.lower()) if "directml" in nuget_file_name.lower(): is_dml_package = True From a3da35b468134f49fd2d4507dc6ec33913b61654 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 20 Dec 2023 23:54:05 +0800 Subject: [PATCH 33/42] update validate --- tools/nuget/validate_package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 50ad2deaecff7..7488b25027b2f 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -116,7 +116,7 @@ def check_if_dlls_are_present( package_contains_library = not bool(package_type == "nuget" and is_gpu_package) # In Nuget GPU package, gpu header files are not in dependent package. package_contains_headers = bool( - (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_dependent_package) + (is_gpu_package and package_type != "nuget") or (package_type == "nuget" and not is_gpu_package) ) # In Nuget GPU package, cuda ep and tensorrt ep dlls are in dependent package package_contains_cuda_binaries = bool((is_gpu_package and package_type != "nuget") or is_gpu_dependent_package) From 0c277f8dd8d021bbf8264df89ef3dcb9f7509695 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 01:01:02 +0800 Subject: [PATCH 34/42] fix --- tools/nuget/validate_package.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 7488b25027b2f..9669361209862 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -111,7 +111,7 @@ def check_if_dlls_are_present( file_list_in_package += [os.path.join(dirpath, file) for file in filenames] else: file_list_in_package = zip_file.namelist() - + print(file_list_in_package) # In Nuget GPU package, onnxruntime.dll is in dependent package. package_contains_library = not bool(package_type == "nuget" and is_gpu_package) # In Nuget GPU package, gpu header files are not in dependent package. @@ -126,7 +126,7 @@ def check_if_dlls_are_present( if package_type == "nuget": folder = "runtimes/" + platform + "/" + native_folder - build_dir = "buildTransitive" if is_gpu_package else "build" + build_dir = "buildTransitive" if is_gpu_dependent_package else "build" header_folder = f"{build_dir}/native/include" else: # zip package folder = package_path + "/lib" @@ -139,7 +139,6 @@ def check_if_dlls_are_present( if path not in file_list_in_package: print("onnxruntime.dll not found for " + platform) raise Exception("onnxruntime.dll not found for " + platform) - continue if package_contains_cuda_binaries: for dll in win_gpu_package_libraries: @@ -163,7 +162,7 @@ def check_if_dlls_are_present( elif platform.startswith("linux"): if package_type == "nuget": folder = "runtimes/" + platform + "/native" - build_dir = "buildTransitive" if is_gpu_package else "build" + build_dir = "buildTransitive" if is_gpu_dependent_package else "build" header_folder = f"{build_dir}/native/include" else: # tarball package folder = package_path + "/lib" @@ -295,8 +294,9 @@ def validate_nuget(args): full_nuget_path = os.path.join(args.package_path, nuget_file_name) is_gpu_package = bool("microsoft.ml.onnxruntime.gpu.1" in args.package_name.lower()) - is_gpu_dependent_package = bool("microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() or "microsoft.ml.onnnxruntime.linux" in args.package_name.lower()) - + is_gpu_dependent_package = bool("microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() or "microsoft.ml.onnnxruntime.gpu.linux" in args.package_name.lower()) + print("is_gpu_package: " + str(is_gpu_package)) + print("is_gpu_dependent_package: " + str(is_gpu_dependent_package)) if "directml" in nuget_file_name.lower(): is_dml_package = True else: From 2fbde0e2bad165f1fd8d7cd0158762f715e42c1f Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 09:14:57 +0800 Subject: [PATCH 35/42] typo --- tools/nuget/validate_package.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index 9669361209862..e29eef811d36a 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -294,9 +294,7 @@ def validate_nuget(args): full_nuget_path = os.path.join(args.package_path, nuget_file_name) is_gpu_package = bool("microsoft.ml.onnxruntime.gpu.1" in args.package_name.lower()) - is_gpu_dependent_package = bool("microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() or "microsoft.ml.onnnxruntime.gpu.linux" in args.package_name.lower()) - print("is_gpu_package: " + str(is_gpu_package)) - print("is_gpu_dependent_package: " + str(is_gpu_dependent_package)) + is_gpu_dependent_package = bool("microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() or "microsoft.ml.onnxruntime.gpu.linux" in args.package_name.lower()) if "directml" in nuget_file_name.lower(): is_dml_package = True else: From 11834ba0d0237db0e8e1dbe683a30c4607f9301a Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 09:29:03 +0800 Subject: [PATCH 36/42] add tests for new Gpu.Windows and Gpu.Linux --- .../c-api-noopenmp-packaging-pipelines.yml | 21 +++++++++++++++++++ .../nuget/templates/test_linux.yml | 3 ++- .../nuget/templates/test_win.yml | 4 +++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 8b1bd571fd3da..fae31251065a3 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -1135,6 +1135,17 @@ stages: SpecificArtifact: ${{ parameters.SpecificArtifact }} BuildId: ${{ parameters.BuildId }} +- template: nuget/templates/test_win.yml + parameters: + AgentPool : 'onnxruntime-Win2022-GPU-T4' + NugetPackageName : 'Microsoft.ML.OnnxRuntime.Gpu.Windows' + ArtifactSuffix: 'GPU' + StageSuffix: 'GPU' + MoreSuffix: '_Windows' + Skipx86Tests: 'true' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} + - template: nuget/templates/test_linux.yml parameters: AgentPool : Onnxruntime-Linux-GPU @@ -1144,6 +1155,16 @@ stages: SpecificArtifact: ${{ parameters.specificArtifact }} BuildId: ${{ parameters.BuildId }} +- template: nuget/templates/test_linux.yml + parameters: + AgentPool : Onnxruntime-Linux-GPU + ArtifactSuffix: 'GPU' + StageSuffix: 'GPU' + MoreSuffix: '_Linux' + NugetPackageName : 'Microsoft.ML.OnnxRuntime.Gpu.Linux' + SpecificArtifact: ${{ parameters.specificArtifact }} + BuildId: ${{ parameters.BuildId }} + - template: nuget/templates/test_linux.yml parameters: AgentPool: AMD-GPU diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml index 1e609b052b8d3..f735755b04bb3 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml @@ -3,13 +3,14 @@ parameters: ArtifactSuffix: '' NugetPackageName : '' StageSuffix: 'CPU' + MoreSuffix: '' NativePackagePrefix: 'onnxruntime' SpecificArtifact: false CustomOpArtifactName: 'onnxruntime-linux-x64' BuildId: '0' CudaVersion: '11.8' stages: -- stage: NuGet_Test_Linux_${{ parameters.StageSuffix }} +- stage: NuGet_Test_Linux_${{ parameters.StageSuffix }}${{ parameters.MoreSuffix }} dependsOn: - NuGet_Packaging_${{ parameters.StageSuffix }} condition: succeeded() 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 18006daf403e4..102a037a4a588 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 @@ -3,6 +3,8 @@ parameters: NugetPackageName : '' ArtifactSuffix: '' StageSuffix: 'CPU' + # More Suffix is used to differentiate testing for GPU and GPU-Windows/GPU-Linux packages + MoreSuffix: '' # For inference packages, the test data artifact name is drop-extra and no suffix is required. # For training packages, to differentiate the artifact name we add '-training' suffix. This needs to be passed from # the parent pipeline. @@ -13,7 +15,7 @@ parameters: BuildId: '' stages: -- stage: NuGet_Test_Win_${{ parameters.StageSuffix }} +- stage: NuGet_Test_Win_${{ parameters.StageSuffix }}${{ parameters.MoreSuffix }} dependsOn: - NuGet_Packaging_${{ parameters.StageSuffix }} condition: succeeded() From 857c62afe276186830a051b91d6fae9130a8c8cf Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 13:27:00 +0800 Subject: [PATCH 37/42] update --- .../c-api-noopenmp-packaging-pipelines.yml | 7 +++-- .../nuget/generate_nuspec_for_native_nuget.py | 29 ++++++++++++------- tools/nuget/validate_package.py | 5 +++- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index fae31251065a3..badee79fd78b3 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -708,6 +708,8 @@ stages: variables: breakCodesignValidationInjection: ${{ parameters.DoEsrp }} ReleaseVersionSuffix: $[stageDependencies.Setup.Set_Variables.outputs['Set_Release_Version_Suffix.ReleaseVersionSuffix']] + BuildDate: $[format('{0:yyyyMMdd}', pipeline.startTime)] + BuildTime: $[format('{0:HHmm}', pipeline.startTime)] steps: - checkout: self @@ -808,12 +810,13 @@ stages: DoEsrp: ${{ parameters.DoEsrp }} - task: MSBuild@1 - displayName: 'Build Primary Nuget Packages Microsoft.ML.OnnxRuntime.Gpu' + displayName: 'Build Nuget Packages Microsoft.ML.OnnxRuntime.Gpu' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-t:CreatePackage -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} + -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:CurrentDate=$(BuildDate) -p:CurrentTime=$(BuildTime)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: BatchScript@1 diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 212d6a0313f7d..94f151c1e4535 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -46,6 +46,7 @@ def is_this_file_needed(ep, filename, package_name): return False return (ep != "cuda" or "cuda" in filename) and (ep != "tensorrt" or "cuda" not in filename) + # nuget_artifacts_dir: the directory with uncompressed C API tarball/zip files # ep: cuda, tensorrt, None # files_list: a list of xml string pieces to append @@ -60,7 +61,11 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, child = child / "lib" # noqa: PLW2901 for child_file in child.iterdir(): suffixes = [".dll", ".lib", ".pdb"] if include_pdbs else [".dll", ".lib"] - if child_file.suffix in suffixes and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Linux": + if ( + child_file.suffix in suffixes + and is_this_file_needed(ep, child_file.name, package_name) + and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Linux" + ): files_list.append( '' % cpu_arch ) @@ -86,7 +91,11 @@ def generate_file_list_for_ep(nuget_artifacts_dir, ep, files_list, include_pdbs, for child_file in child.iterdir(): if not child_file.is_file(): continue - if child_file.suffix == ".so" and is_this_file_needed(ep, child_file.name, package_name) and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Windows": + if ( + child_file.suffix == ".so" + and is_this_file_needed(ep, child_file.name, package_name) + and package_name != "Microsoft.ML.OnnxRuntime.Gpu.Windows" + ): files_list.append( '' % cpu_arch ) @@ -131,7 +140,9 @@ def parse_arguments(): help="The selected execution provider for this build.", ) parser.add_argument("--sdk_info", required=False, default="", type=str, help="dependency SDK information.") - parser.add_argument("--nuspec_name", required=False, default="NativeNuget.nuspec", type=str, help="nuget spec name.") + parser.add_argument( + "--nuspec_name", required=False, default="NativeNuget.nuspec", type=str, help="nuget spec name." + ) return parser.parse_args() @@ -170,14 +181,12 @@ def generate_description(line_list, package_name): "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." ) elif "Microsoft.ML.OnnxRuntime.Gpu.Linux" in package_name: - description = ( - "This package contains Linux native shared library artifacts for ONNX Runtime with CUDA." - ) + description = "This package contains Linux native shared library artifacts for ONNX Runtime with CUDA." elif "Microsoft.ML.OnnxRuntime.Gpu.Windows" in package_name: - description = ( - "This package contains Windows native shared library artifacts for ONNX Runtime with CUDA." - ) - elif "Microsoft.ML.OnnxRuntime.Gpu.1" in package_name: # This is a Microsoft.ML.OnnxRuntime.GPU.* package, 1 is begin of version, that is used to filter Gpu.Windows/Gpu.linux + description = "This package contains Windows native shared library artifacts for ONNX Runtime with CUDA." + elif ( + "Microsoft.ML.OnnxRuntime.Gpu.1" in package_name + ): # This is a Microsoft.ML.OnnxRuntime.GPU.* package, 1 is begin of version, that is used to filter Gpu.Windows/Gpu.linux description = ( "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." ) diff --git a/tools/nuget/validate_package.py b/tools/nuget/validate_package.py index e29eef811d36a..1079b64c9a90f 100644 --- a/tools/nuget/validate_package.py +++ b/tools/nuget/validate_package.py @@ -294,7 +294,10 @@ def validate_nuget(args): full_nuget_path = os.path.join(args.package_path, nuget_file_name) is_gpu_package = bool("microsoft.ml.onnxruntime.gpu.1" in args.package_name.lower()) - is_gpu_dependent_package = bool("microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() or "microsoft.ml.onnxruntime.gpu.linux" in args.package_name.lower()) + is_gpu_dependent_package = bool( + "microsoft.ml.onnxruntime.gpu.windows" in args.package_name.lower() + or "microsoft.ml.onnxruntime.gpu.linux" in args.package_name.lower() + ) if "directml" in nuget_file_name.lower(): is_dml_package = True else: From c1d02b3c906b9c16daf798730971d17cb43f4e47 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 13:33:11 +0800 Subject: [PATCH 38/42] update description --- tools/nuget/generate_nuspec_for_native_nuget.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 94f151c1e4535..b0a0326c9e833 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -176,17 +176,15 @@ def generate_description(line_list, package_name): + "See https://github.com/microsoft/onnxruntime-training-examples/tree/master/on_device_training for " + "more details." ) - elif "Microsoft.ML.OnnxRuntime" in package_name: # This is a Microsoft.ML.OnnxRuntime.* package + elif "Microsoft.ML.OnnxRuntime.Gpu.Linux" in package_name: + description = ("This package contains Linux native shared library artifacts for ONNX Runtime with CUDA.") + elif "Microsoft.ML.OnnxRuntime.Gpu.Windows" in package_name: + description = ("This package contains Windows native shared library artifacts for ONNX Runtime with CUDA.") + elif "Microsoft.ML.OnnxRuntime.Gpu" in package_name: description = ( "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." ) - elif "Microsoft.ML.OnnxRuntime.Gpu.Linux" in package_name: - description = "This package contains Linux native shared library artifacts for ONNX Runtime with CUDA." - elif "Microsoft.ML.OnnxRuntime.Gpu.Windows" in package_name: - description = "This package contains Windows native shared library artifacts for ONNX Runtime with CUDA." - elif ( - "Microsoft.ML.OnnxRuntime.Gpu.1" in package_name - ): # This is a Microsoft.ML.OnnxRuntime.GPU.* package, 1 is begin of version, that is used to filter Gpu.Windows/Gpu.linux + elif "Microsoft.ML.OnnxRuntime" in package_name: # This is a Microsoft.ML.OnnxRuntime.* package description = ( "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." ) From 1618cf24093d8a9da85389769109a1815a114cbe Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 15:42:20 +0800 Subject: [PATCH 39/42] run gpu test with new package --- .../Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat | 7 +++++-- .../test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat index 07128fe1620ab..c16f12dc17f79 100755 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.bat @@ -52,9 +52,12 @@ IF NOT errorlevel 0 ( %dn% list test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj package dir test\Microsoft.ML.OnnxRuntime.EndToEndTests\packages\ -IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu" ( +set gpu_package=F +IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu" set gpu_package=T +IF "%PACKAGENAME%"=="Microsoft.ML.OnnxRuntime.Gpu.Windows" set gpu_package=T +IF %%gpu_package%%=="T" ( set TESTONGPU=ON - %dn% test -p:DefineConstants=USE_TENSORRT test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --filter TensorRT + %dn% test -p:DefineConstants=USE_TENSORRT test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --filter TensorRT IF NOT errorlevel 0 ( @echo "Failed to build or execute the end-to-end test" diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh index 39f0ff1c2f85e..a500e4bce8fbf 100755 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh @@ -32,7 +32,7 @@ if [ $RunTestCsharp = "true" ]; then exit 1 fi - if [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu" ]; then + if [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu" ] || [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu.Linux" ]; then export TESTONGPU=ON dotnet test -p:DefineConstants=USE_CUDA $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed if [ $? -ne 0 ]; then From 78c0c55b842664bd4e8bbe8c390181af1a89f740 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Thu, 21 Dec 2023 18:01:31 +0800 Subject: [PATCH 40/42] Update tools/nuget/generate_nuspec_for_native_nuget.py Co-authored-by: Scott McKay --- tools/nuget/generate_nuspec_for_native_nuget.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index b0a0326c9e833..cedd31b9a757c 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -180,10 +180,6 @@ def generate_description(line_list, package_name): description = ("This package contains Linux native shared library artifacts for ONNX Runtime with CUDA.") elif "Microsoft.ML.OnnxRuntime.Gpu.Windows" in package_name: description = ("This package contains Windows native shared library artifacts for ONNX Runtime with CUDA.") - elif "Microsoft.ML.OnnxRuntime.Gpu" in package_name: - description = ( - "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." - ) elif "Microsoft.ML.OnnxRuntime" in package_name: # This is a Microsoft.ML.OnnxRuntime.* package description = ( "This package contains native shared library artifacts for all supported platforms of ONNX Runtime." From 84e24c99d5d81e693eedb6b84249bdcff01b1c4f Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 22 Dec 2023 10:48:04 +0800 Subject: [PATCH 41/42] wording --- csharp/OnnxRuntime.CSharp.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index 6a8dcb4378c21..ae9b3750ec893 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -99,8 +99,8 @@ CMake creates a target to this project - - + + From 6af5361165ece5144d5de11500badce65e68c02d Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 22 Dec 2023 13:21:44 +0800 Subject: [PATCH 42/42] fix lint --- tools/nuget/generate_nuspec_for_native_nuget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index cedd31b9a757c..66248565a3e3a 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -177,9 +177,9 @@ def generate_description(line_list, package_name): + "more details." ) elif "Microsoft.ML.OnnxRuntime.Gpu.Linux" in package_name: - description = ("This package contains Linux native shared library artifacts for ONNX Runtime with CUDA.") + description = "This package contains Linux native shared library artifacts for ONNX Runtime with CUDA." elif "Microsoft.ML.OnnxRuntime.Gpu.Windows" in package_name: - description = ("This package contains Windows native shared library artifacts for ONNX Runtime with CUDA.") + description = "This package contains Windows native shared library artifacts for ONNX Runtime with CUDA." elif "Microsoft.ML.OnnxRuntime" in package_name: # This is a Microsoft.ML.OnnxRuntime.* package description = ( "This package contains native shared library artifacts for all supported platforms of ONNX Runtime."