Skip to content

Commit

Permalink
Cherry-picks pipeline changes to 1.16.0 release branch (#17577)
Browse files Browse the repository at this point in the history
### Description
1. Delete Prefast tasks (#17522)
2. Disable yum update (#17551)
3. Avoid calling patchelf (#17365 and #17562) we that we can validate
the above fix

The main problem I'm trying to solve is: our GPU package depends on both
CUDA 11.x and CUDA 12.x . However, it's not easy to see the information
because ldd doesn't work with the shared libraries we generate(see issue
#9754) . So the patchelf change are useful for me to validate the
"Disabling yum update" was successful. As you can see we call "yum
update" from multiple places. Without some kind of validation it's hard
to say if I have covered all of them.
The Prefast change is needed because I'm going to update the VM images
in the next a few weeks. In case of we need to publish a patch release
after that.

### Motivation and Context
Without this fix we will mix using CUDA 11.x and CUDA 12.x. And it will
crash every time when we use TensorRT.
  • Loading branch information
snnn authored Sep 18, 2023
1 parent 06ea28b commit e7a0495
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 445 deletions.
133 changes: 0 additions & 133 deletions .github/workflows/sca.yml

This file was deleted.

134 changes: 33 additions & 101 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datetime
import logging
import platform
import shlex
import subprocess
import sys
from glob import glob, iglob
Expand Down Expand Up @@ -183,108 +184,37 @@ def run(self):
dest = "onnxruntime/capi/onnxruntime_pybind11_state_manylinux1.so"
logger.info("copying %s -> %s", source, dest)
copyfile(source, dest)
result = subprocess.run(
["patchelf", "--print-needed", dest], check=True, stdout=subprocess.PIPE, text=True
)
dependencies = [
"librccl.so",
"libamdhip64.so",
"librocblas.so",
"libMIOpen.so",
"libhsa-runtime64.so",
"libhsakmt.so",
]

to_preload = []
to_preload_cuda = []
to_preload_tensorrt = []
to_preload_cann = []
cuda_dependencies = []
args = ["patchelf", "--debug"]
for line in result.stdout.split("\n"):
for dependency in dependencies:
if dependency in line:
to_preload.append(line)
args.extend(["--remove-needed", line])
args.append(dest)
if len(args) > 3:
subprocess.run(args, check=True, stdout=subprocess.PIPE)

dest = "onnxruntime/capi/libonnxruntime_providers_" + ("rocm.so" if is_rocm else "cuda.so")
if path.isfile(dest):
result = subprocess.run(
["patchelf", "--print-needed", dest],
check=True,
stdout=subprocess.PIPE,
text=True,
)
cuda_dependencies = [
"libcublas.so",
"libcublasLt.so",
"libcudnn.so",
"libcudart.so",
"libcurand.so",
"libcufft.so",
"libnvToolsExt.so",
"libcupti.so",
]
rocm_dependencies = [
"librccl.so",
"libamdhip64.so",
"librocblas.so",
"libMIOpen.so",
"libhsa-runtime64.so",
"libhsakmt.so",
]
args = ["patchelf", "--debug"]
for line in result.stdout.split("\n"):
for dependency in cuda_dependencies + rocm_dependencies:
if dependency in line:
if dependency not in to_preload:
to_preload_cuda.append(line)
args.extend(["--remove-needed", line])
args.append(dest)
if len(args) > 3:
subprocess.run(args, check=True, stdout=subprocess.PIPE)

dest = "onnxruntime/capi/libonnxruntime_providers_" + ("migraphx.so" if is_rocm else "tensorrt.so")
if path.isfile(dest):
result = subprocess.run(
["patchelf", "--print-needed", dest],
check=True,
stdout=subprocess.PIPE,
text=True,
)
tensorrt_dependencies = ["libnvinfer.so", "libnvinfer_plugin.so", "libnvonnxparser.so"]
args = ["patchelf", "--debug"]
for line in result.stdout.split("\n"):
for dependency in cuda_dependencies + tensorrt_dependencies:
if dependency in line:
if dependency not in (to_preload + to_preload_cuda):
to_preload_tensorrt.append(line)
args.extend(["--remove-needed", line])
args.append(dest)
if len(args) > 3:
subprocess.run(args, check=True, stdout=subprocess.PIPE)

dest = "onnxruntime/capi/libonnxruntime_providers_cann.so"
if path.isfile(dest):
result = subprocess.run(
["patchelf", "--print-needed", dest],
check=True,
stdout=subprocess.PIPE,
text=True,
)
cann_dependencies = ["libascendcl.so", "libacl_op_compiler.so", "libfmk_onnx_parser.so"]
args = ["patchelf", "--debug"]
for line in result.stdout.split("\n"):
for dependency in cann_dependencies:
if dependency in line:
if dependency not in to_preload:
to_preload_cann.append(line)
args.extend(["--remove-needed", line])
args.append(dest)
if len(args) > 3:
subprocess.run(args, check=True, stdout=subprocess.PIPE)

cuda_dependencies = [
"libcublas.so.11",
"libcublasLt.so.11",
"libcudnn.so.8",
"libcudart.so.11.0",
"libcurand.so.10",
"libcufft.so.10",
]
rocm_dependencies = [
"librccl.so.1",
"libnuma.so.1",
"libamd_comgr.so.2",
"libdrm.so.2",
"librocblas.so.0",
"libdrm_amdgpu.so.1",
"libamdhip64.so.5",
"libroctracer64.so.4",
"libMIOpen.so.1",
"libtinfo.so.6",
"libelf.so.1",
"librocm_smi64.so.5",
"libhsa-runtime64.so.1",
]

tensorrt_dependencies = ["libnvinfer.so.8", "libnvinfer_plugin.so.8", "libnvonnxparser.so.8"]

dest = "onnxruntime/capi/libonnxruntime_providers_openvino.so"
if path.isfile(dest):
Expand All @@ -308,10 +238,12 @@ def run(self):
assert self.dist_dir is not None
file = glob(path.join(self.dist_dir, "*linux*.whl"))[0]
logger.info("repairing %s for manylinux1", file)
auditwheel_cmd = ["auditwheel", "-v", "repair", "-w", self.dist_dir, file]
for i in cuda_dependencies + rocm_dependencies + tensorrt_dependencies:
auditwheel_cmd += ["--exclude", i]
logger.info("Running {}".format(" ".join([shlex.quote(arg) for arg in auditwheel_cmd])))
try:
subprocess.run(
["auditwheel", "repair", "-w", self.dist_dir, file], check=True, stdout=subprocess.PIPE
)
subprocess.run(auditwheel_cmd, check=True, stdout=subprocess.PIPE)
finally:
logger.info("removing %s", file)
remove(file)
Expand Down
5 changes: 0 additions & 5 deletions tools/ci_build/github/azure-pipelines/post-merge-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ stages:
isX86: false
job_name_suffix: x64_RelWithDebInfo
RunOnnxRuntimeTests: true
RunStaticCodeAnalysis: false
ORT_EP_NAME: CUDA
WITH_CACHE: true
MachinePool: onnxruntime-Win2022-GPU-MultiA10
Expand All @@ -93,7 +92,6 @@ stages:
isX86: false
job_name_suffix: x64_mimalloc
RunOnnxRuntimeTests: true
RunStaticCodeAnalysis: false
isTraining: false
ORT_EP_NAME: CPU
GenerateDocumentation: false
Expand All @@ -113,7 +111,6 @@ stages:
isX86: false
job_name_suffix: x64_no_memory_profiling
RunOnnxRuntimeTests: false
RunStaticCodeAnalysis: false
isTraining: false
ORT_EP_NAME: CPU
GenerateDocumentation: false
Expand All @@ -133,7 +130,6 @@ stages:
isX86: false
job_name_suffix: x64_minimal_no_exception
RunOnnxRuntimeTests: true
RunStaticCodeAnalysis: false
isTraining: false
ORT_EP_NAME: CPU
GenerateDocumentation: false
Expand All @@ -153,7 +149,6 @@ stages:
isX86: false
job_name_suffix: x64_debug_node_input_output
RunOnnxRuntimeTests: true
RunStaticCodeAnalysis: false
isTraining: false
ORT_EP_NAME: CPU
GenerateDocumentation: false
Expand Down
21 changes: 0 additions & 21 deletions tools/ci_build/github/azure-pipelines/templates/compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@ steps:
arguments: 'analyze $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.dll --recurse --verbose'
continueOnError: true

- task: DeleteFiles@1
displayName: 'Delete files from $(Build.BinariesDirectory)\RelWithDebInfo'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\RelWithDebInfo'
Contents: |
**/*.obj
**/*.pdb
**/*.dll
# Manually set msBuildCommandline so that we can also set CAExcludePath
- task: SDLNativeRules@3
displayName: 'Run the PREfast SDL Native Rules for MSBuild'
inputs:
userProvideBuildInfo: msBuildInfo
msBuildArchitecture: x64
msBuildVersion: 17.0
msBuildCommandline: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\msbuild.exe" "$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln" /p:platform="${{parameters.msbuildPlatform}}" /p:configuration="RelWithDebInfo" /p:CAExcludePath="$(Build.BinariesDirectory);$(Build.SourcesDirectory)\cmake;C:\program files (x86)" /p:VisualStudioVersion="17.0" /m /p:PreferredToolArchitecture=x64'
excludedPaths: '$(Build.SourcesDirectory)\b#$(Build.SourcesDirectory)\cmake#C:\program files#C:\program files (x86)#C:\program files'
rulesetName: Custom
customRuleset: $(Build.SourcesDirectory)\cmake\Sdl.ruleset

- task: SdtReport@2
displayName: 'Create Security Analysis Report'
inputs:
Expand Down
Loading

0 comments on commit e7a0495

Please sign in to comment.