Skip to content

Commit

Permalink
Enable VCPKG in more pipelines (#23590)
Browse files Browse the repository at this point in the history
### Description
Enable VCPKG in more pipelines
  • Loading branch information
snnn authored Feb 6, 2025
1 parent 6728d60 commit 328a13c
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 52 deletions.
5 changes: 2 additions & 3 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -600,16 +600,15 @@ endif()

if(onnxruntime_ENABLE_DLPACK)
message(STATUS "dlpack is enabled.")

onnxruntime_fetchcontent_declare(
dlpack
URL ${DEP_URL_dlpack}
URL_HASH SHA1=${DEP_SHA1_dlpack}
EXCLUDE_FROM_ALL
FIND_PACKAGE_ARGS NAMES dlpack
)
# We can't use onnxruntime_fetchcontent_makeavailable since some part of the the dlpack code is Linux only.
# For example, dlpackcpp.h uses posix_memalign.
FetchContent_Populate(dlpack)
onnxruntime_fetchcontent_makeavailable(dlpack)
endif()

if(onnxruntime_ENABLE_TRAINING OR (onnxruntime_ENABLE_TRAINING_APIS AND onnxruntime_BUILD_UNIT_TESTS))
Expand Down
7 changes: 2 additions & 5 deletions cmake/onnxruntime_framework.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,15 @@ endif()
if (onnxruntime_ENABLE_TRAINING_OPS)
target_include_directories(onnxruntime_framework PRIVATE ${ORTTRAINING_ROOT})
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP OR onnxruntime_ENABLE_TRITON)
onnxruntime_add_include_to_target(onnxruntime_framework Python::Module)
target_include_directories(onnxruntime_framework PRIVATE ${dlpack_SOURCE_DIR}/include)
onnxruntime_add_include_to_target(onnxruntime_framework Python::Module dlpack::dlpack)
endif()
endif()
if (onnxruntime_USE_MPI)
target_include_directories(onnxruntime_framework PUBLIC ${MPI_CXX_INCLUDE_DIRS})
endif()

if (onnxruntime_ENABLE_ATEN)
# DLPack is a header-only dependency
set(DLPACK_INCLUDE_DIR ${dlpack_SOURCE_DIR}/include)
target_include_directories(onnxruntime_framework PRIVATE ${DLPACK_INCLUDE_DIR})
onnxruntime_add_include_to_target(onnxruntime_framework dlpack::dlpack)
endif()
onnxruntime_add_include_to_target(onnxruntime_framework onnxruntime_common onnx onnx_proto ${PROTOBUF_LIB} flatbuffers::flatbuffers safeint_interface Boost::mp11 nlohmann_json::nlohmann_json)

Expand Down
3 changes: 1 addition & 2 deletions cmake/onnxruntime_providers_cpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ endif()
if (onnxruntime_ENABLE_DLPACK)
target_compile_definitions(onnxruntime_providers PRIVATE ENABLE_DLPACK)
# DLPack is a header-only dependency
set(DLPACK_INCLUDE_DIR ${dlpack_SOURCE_DIR}/include)
target_include_directories(onnxruntime_providers PRIVATE ${DLPACK_INCLUDE_DIR})
onnxruntime_add_include_to_target(onnxruntime_providers dlpack::dlpack)
endif()

if (onnxruntime_ENABLE_TRAINING)
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ if (onnxruntime_ENABLE_ATEN)
endif()

if (onnxruntime_ENABLE_DLPACK)
target_include_directories(onnxruntime_pybind11_state PRIVATE ${dlpack_SOURCE_DIR}/include)
target_link_libraries(onnxruntime_pybind11_state PRIVATE dlpack::dlpack)
endif()

if (onnxruntime_ENABLE_TRAINING)
Expand Down
4 changes: 3 additions & 1 deletion tools/ci_build/github/android/build_aar_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def _build_aar(args):
aar_dir = os.path.join(intermediates_dir, "aar", build_config)
jnilibs_dir = os.path.join(intermediates_dir, "jnilibs", build_config)
exe_dir = os.path.join(intermediates_dir, "executables", build_config)
base_build_command = [sys.executable, BUILD_PY] + build_settings["build_params"] + ["--config=" + build_config]
base_build_command = (
[sys.executable, BUILD_PY] + build_settings["build_params"] + ["--config=" + build_config, "--use_vcpkg"]
)
header_files_path = ""

if qnn_android_build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
--android_ndk_path $ANDROID_NDK_HOME \
--android_abi=x86_64 \
--android_api=31 \
--parallel \
--parallel --use_vcpkg \
--build_shared_lib \
--use_qnn static_lib \
--qnn_home $(QnnSDKRootDir) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ stages:
--android_abi=x86_64 \
--android_api=30 \
--skip_submodule_sync \
--parallel \
--parallel --use_vcpkg \
--cmake_generator=Ninja \
--build_java
displayName: CPU EP, Build and Test
Expand Down Expand Up @@ -158,7 +158,7 @@ stages:
--android_abi=x86_64 \
--android_api=29 \
--skip_submodule_sync \
--parallel \
--parallel --use_vcpkg \
--use_nnapi \
--build_shared_lib \
--cmake_generator=Ninja \
Expand Down Expand Up @@ -218,7 +218,7 @@ stages:
--android_abi=x86_64 \
--android_api=29 \
--skip_submodule_sync \
--parallel \
--parallel --use_vcpkg \
--use_nnapi \
--build_shared_lib \
--cmake_generator=Ninja \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ stages:
--config Release --update --build \
--skip_submodule_sync \
--build_shared_lib \
--parallel \
--parallel --use_vcpkg \
--build_wheel \
--enable_onnx_tests --use_cuda --cuda_version=11.8 --cuda_home=/usr/local/cuda-11.8 --cudnn_home=/usr/local/cuda-11.8 \
--enable_cuda_profiling \
Expand Down
6 changes: 3 additions & 3 deletions tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ stages:
--config Debug \
--skip_submodule_sync \
--build_shared_lib \
--parallel \
--parallel --use_vcpkg \
--enable_onnx_tests --enable_address_sanitizer \
--update --build;
python3 /onnxruntime_src/tools/ci_build/build.py \
--build_dir /build --cmake_generator Ninja \
--config Debug \
--skip_submodule_sync \
--build_shared_lib \
--parallel \
--parallel --use_vcpkg \
--enable_onnx_tests --enable_address_sanitizer \
--test;
'
Expand Down Expand Up @@ -199,7 +199,7 @@ stages:
--config Release \
--skip_submodule_sync \
--build_shared_lib \
--parallel --use_binskim_compliant_compile_flags \
--parallel --use_vcpkg --use_binskim_compliant_compile_flags \
--build_wheel \
--build_csharp \
--enable_onnx_tests \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
--config Debug Release \
--skip_submodule_sync \
--build_shared_lib \
--parallel \
--parallel --use_vcpkg \
--enable_pybind \
--enable_onnx_tests \
--build_java \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ stages:
cd /onnxruntime_src/java && /onnxruntime_src/java/gradlew cmakeCheck -DcmakeBuildDir=/build/Release -DUSE_CUDA=1; \
cd /tmp; \
python3 /onnxruntime_src/tools/ci_build/build.py \
--build_dir /build --config Release --test --skip_submodule_sync --build_shared_lib --parallel --use_binskim_compliant_compile_flags --build_wheel --enable_onnx_tests \
--build_dir /build --config Release --test --skip_submodule_sync --build_shared_lib --parallel --use_vcpkg --use_binskim_compliant_compile_flags --build_wheel --enable_onnx_tests \
--enable_transformers_tool_test --use_cuda --cuda_version=${{parameters.CudaVersion}} --cuda_home=/usr/local/cuda --cudnn_home=/usr/local/cuda \
--enable_pybind --build_java --ctest_path "" ; \
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
--use_qnn $(QnnLibKind) \
--qnn_home $(QnnSDKRootDir) \
--cmake_generator=Ninja \
--update --build --parallel
--update --build --parallel --use_vcpkg
displayName: Build QNN EP
- script: |
Expand All @@ -87,7 +87,7 @@ jobs:
--use_qnn $(QnnLibKind) \
--qnn_home $(QnnSDKRootDir) \
--cmake_generator=Ninja \
--test
--test --use_vcpkg
displayName: Run unit tests
- task: CmdLine@2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jobs:
--enable_nccl \
--build_dir /build \
--build_shared_lib \
--parallel \
--parallel --use_vcpkg \
--build_wheel \
--skip_submodule_sync \
--test --enable_onnx_tests --enable_transformers_tool_test \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
--build_dir build \
--skip_submodule_sync \
--cmake_generator=Ninja \
--parallel --use_binskim_compliant_compile_flags \
--parallel --use_vcpkg --use_binskim_compliant_compile_flags \
--build_shared_lib \
--config Debug \
--use_cache \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ stages:
- ${{ else }}:
- powershell: |
python tools\ci_build\build.py ${{ parameters.BuildCommand }} --use_binskim_compliant_compile_flags --parallel --build_csharp --build --update --config $(BuildConfig) --build_nuget --msbuild_extra_options IncludeMobileTargets=false ${{ variables.build_py_lto_flag }}
python tools\ci_build\build.py ${{ parameters.BuildCommand }} --use_binskim_compliant_compile_flags --parallel --use_vcpkg --build_csharp --build --update --config $(BuildConfig) --build_nuget --msbuild_extra_options IncludeMobileTargets=false ${{ variables.build_py_lto_flag }}
- ${{ if notIn(parameters['sln_platform'], 'Win32', 'x64') }}:
# Use cross-compiled protoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ stages:
set -e -x
export _PYTHON_HOST_PLATFORM=macosx-${{variables.MACOSX_DEPLOYMENT_TARGET}}-universal2
python3 -m pip install -r '$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/scripts/requirements.txt'
python3 $(Build.SourcesDirectory)/tools/ci_build/build.py --build_dir $(Build.BinariesDirectory) --use_coreml --skip_submodule_sync --parallel --use_binskim_compliant_compile_flags --config Release --build_wheel ${{ parameters.build_py_parameters }} --use_coreml --cmake_extra_defines CMAKE_OSX_ARCHITECTURES="arm64;x86_64" --update --build
python3 $(Build.SourcesDirectory)/tools/ci_build/build.py --build_dir $(Build.BinariesDirectory) --use_coreml --skip_submodule_sync --parallel --use_vcpkg --use_binskim_compliant_compile_flags --config Release --build_wheel ${{ parameters.build_py_parameters }} --use_coreml --cmake_extra_defines CMAKE_OSX_ARCHITECTURES="arm64;x86_64" --update --build
displayName: 'Command Line Script'
- script: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ stages:
--cmake_generator "$(VSGenerator)"
--enable_pybind
--enable_onnx_tests
--parallel 8 --use_binskim_compliant_compile_flags --update --build --msvc_toolset 14.40
--parallel 8 --use_vcpkg --use_binskim_compliant_compile_flags --update --build --msvc_toolset 14.40
$(TelemetryOption) ${{ parameters.BUILD_PY_PARAMETERS }} ${{ parameters.EP_BUILD_FLAGS }} ${{ variables.trt_build_flag }}
workingDirectory: '$(Build.BinariesDirectory)'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
docker run --rm --volume /data/onnx:/data/onnx:ro --volume $(Build.SourcesDirectory):/onnxruntime_src --volume $(Build.BinariesDirectory):/build \
--volume $HOME/.onnx:/home/onnxruntimedev/.onnx -e NIGHTLY_BUILD onnxruntimecpubuildcentos8${{parameters.OnnxruntimeArch}}_packaging /bin/bash -c "python3 \
/onnxruntime_src/tools/ci_build/build.py --enable_lto --build_java --build_nodejs --build_dir /build --config Release \
--skip_submodule_sync --parallel --use_binskim_compliant_compile_flags --use_vcpkg --build_shared_lib ${{ parameters.AdditionalBuildFlags }} && cd /build/Release && make install DESTDIR=/build/installed"
--skip_submodule_sync --parallel --use_vcpkg --use_binskim_compliant_compile_flags --use_vcpkg --build_shared_lib ${{ parameters.AdditionalBuildFlags }} && cd /build/Release && make install DESTDIR=/build/installed"
mkdir $(Build.ArtifactStagingDirectory)/testdata
cp $(Build.BinariesDirectory)/Release/libcustom_op_library.so* $(Build.ArtifactStagingDirectory)/testdata
ls -al $(Build.ArtifactStagingDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ steps:
- script: |
set -e -x
rm -rf $(Build.BinariesDirectory)/Release
python3 $(Build.SourcesDirectory)/tools/ci_build/build.py --update --build ${{ parameters.AdditionalBuildFlags }} --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --parallel --use_binskim_compliant_compile_flags --build_shared_lib --config Release --use_vcpkg
python3 $(Build.SourcesDirectory)/tools/ci_build/build.py --update --build ${{ parameters.AdditionalBuildFlags }} --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --parallel --use_vcpkg --use_binskim_compliant_compile_flags --build_shared_lib --config Release --use_vcpkg
cd $(Build.BinariesDirectory)/Release
make install DESTDIR=$(Build.BinariesDirectory)/installed
displayName: 'Build ${{ parameters.MacosArch }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
--use_qnn
--qnn_home $(QnnSDKRootDir)
--enable_pybind
--parallel --update
--parallel --use_vcpkg --update
$(TelemetryOption) ${{ parameters.BUILD_PY_PARAMETERS }}
workingDirectory: '$(Build.BinariesDirectory)'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
--use_qnn
--qnn_home $(QnnSDKRootDir)
--enable_pybind
--parallel --update --arm64ec
--parallel --use_vcpkg --update --arm64ec
$(TelemetryOption) ${{ parameters.BUILD_PY_PARAMETERS }}
workingDirectory: '$(Build.BinariesDirectory)'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
--use_qnn
--qnn_home $(QnnSDKRootDir)
--enable_pybind
--parallel --update
--parallel --use_vcpkg --update
$(TelemetryOption) ${{ parameters.BUILD_PY_PARAMETERS }}
workingDirectory: '$(Build.BinariesDirectory)'

Expand Down
2 changes: 1 addition & 1 deletion tools/ci_build/github/azure-pipelines/templates/rocm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
--rocm_home=/opt/rocm \
--nccl_home=/opt/rocm \
--update \
--parallel \
--parallel --use_vcpkg \
--build_dir /build \
--build \
--build_wheel \
Expand Down
14 changes: 1 addition & 13 deletions tools/ci_build/github/azure-pipelines/templates/win-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,10 @@ stages:
displayName: 'Generate cmake config'
inputs:
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
arguments: '--config RelWithDebInfo --use_binskim_compliant_compile_flags --enable_lto --disable_rtti --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --cmake_generator "$(VSGenerator)" --enable_onnx_tests $(TelemetryOption) ${{ parameters.buildparameter }} $(timeoutParameter) $(buildJavaParameter)'
arguments: '--config RelWithDebInfo --use_binskim_compliant_compile_flags --enable_lto --disable_rtti --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --build --use_vcpkg --cmake_generator "$(VSGenerator)" --enable_onnx_tests $(TelemetryOption) ${{ parameters.buildparameter }} $(timeoutParameter) $(buildJavaParameter)'
workingDirectory: '$(Build.BinariesDirectory)'


- task: VSBuild@1
displayName: 'Build'
inputs:
solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln'
platform: ${{ parameters.msbuildPlatform }}
configuration: RelWithDebInfo
msbuildArchitecture: ${{ parameters.buildArch }}
maximumCpuCount: true # default is num logical cores worth of projects building concurrently
logProjectEvents: true
workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo'
createLogFile: true

# For CPU job, tests are run in the same machine as building
- ${{ if eq(parameters.buildJava, 'true') }}:
- template: make_java_win_binaries.yml
Expand Down
2 changes: 1 addition & 1 deletion tools/ci_build/github/azure-pipelines/win-ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ stages:
parameters:
BuildConfig: 'RelWithDebInfo'
buildArch: x64
additionalBuildFlags: --build_wheel --use_dnnl
additionalBuildFlags: --build_wheel --use_dnnl --use_vcpkg
msbuildPlatform: x64
isX86: false
job_name_suffix: x64_release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN echo "$APT_PREF" > /etc/apt/preferences.d/rocm-pin-600
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg && \
apt-get install -y --no-install-recommends ca-certificates ninja-build git zip curl libnuma-dev gnupg && \
curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - &&\
printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ jammy main" | tee /etc/apt/sources.list.d/rocm.list && \
printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu jammy main" | tee /etc/apt/sources.list.d/amdgpu.list && \
Expand Down Expand Up @@ -45,10 +45,10 @@ ENV LANG C.UTF-8
WORKDIR /stage

# Cmake
ENV CMAKE_VERSION=3.30.1
ENV CMAKE_VERSION=3.31.5
RUN cd /usr/local && \
wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz && \
tar -zxf /usr/local/cmake-3.30.1-Linux-x86_64.tar.gz --strip=1 -C /usr
tar -zxf /usr/local/cmake-3.31.5-Linux-x86_64.tar.gz --strip=1 -C /usr

# ccache
RUN mkdir -p /tmp/ccache && \
Expand Down

0 comments on commit 328a13c

Please sign in to comment.