Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CMake option onnxruntime_USE_VCPKG #21348

Merged
merged 24 commits into from
Sep 10, 2024
Merged

Conversation

luncliff
Copy link
Contributor

@luncliff luncliff commented Jul 13, 2024

Changes

  1. CMake option onnxruntime_USE_VCPKG. It will be used in the vcpkg port
    • Unit test may fail because this option leads to a mixture of unexpected external library versions.
      Especially ONNX, Protobuf, and Flatbuffers version can be different
  2. Overhaul of onnxruntime_external_deps.cmake
    • Make FetchContent_Declare to try find_package.
      See https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
    • Relocated FetchContent_Declare and FetchContent_MakeAvailable(or onnxruntime_fetchcontent_makeavailable) to closer lines.
      It was too hard to navigate the entire file to search related sections...
    • Alias IMPORTED targets like build targets (e.g. ONNX::onnx --> onnx)
# The script uses `find_package` with the changes.
# In this case, use vcpkg to search dependencies
# See https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
include(external/onnxruntime_external_deps.cmake)
  1. Create CMakePresets.json and presets to run vcpkg in manifest mode
    • Currently, it's NOT for training build
    • Main triplets are x64-windows and x64-osx
Push-Location "cmake"
    cmake --preset "x64-windows-vcpkg"
    cmake --build --preset "x64-windows-vcpkg-debug"
Pop-Location
pushd "cmake"
    cmake --preset "x64-osx-vcpkg"
    cmake --build --preset "x64-osx-vcpkg-debug"
popd
  1. Updated tools/ci_build/build.py
    • --use_vcpkg option: it needs CMAKE_TOOLCHAIN_FILE with vcpkg.cmake toolchain script
    • --compile_no_warning_as_error is recommended because library version differences will cause unexpected compiler warnings
python ./tools/ci_build/build.py \
    --compile_no_warning_as_error \
    --use_vcpkg \
    --cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
    --cmake_extra_defines "VCPKG_TARGET_TRIPLET=..."
  1. Created Job Vcpkg for Windows and macOS
    • Show how to setup and use vcpkg.
      Similar to the CMakePresets.json usage

Motivation and Context

Future Works?

More feature coverage with the vcpkg supported libraries

  • CUDA feature support
  • Training feature support

@luncliff luncliff marked this pull request as draft July 13, 2024 18:15
@luncliff luncliff changed the title Create files and CMake option to support vcpkg and CMakePresets.json to test it Create files and CMake option to support vcpkg Jul 13, 2024
@snnn
Copy link
Member

snnn commented Jul 15, 2024

I think cmake is a great choice.
Which cmake triplet this PR is going to support?

Besides, we might decouple the work. You may create a vcpkg config file, then install all the packages via "vcpkg install", then let cmake search installed packages there when running ONNX Runtime's build.py script. Then in theory you don't need to modify any ONNX Runtime's cmake file. No matter which way you choose to go, we always greatly appreciate your contribution.

@luncliff
Copy link
Contributor Author

36919b0 New GitHub Actions jobs for vcpkg build

6227f5f Trying to merge onnxruntime_vcpkg_deps.cmake into onnxruntime_external_deps.cmake using FIND_PACKAGE_ARGS .
Currently I have some problems with pb.h,pb.cc generation

* Detect protoc path for build.py
* Run vcpkg for each build.py run

Reorganized vcpkg install folder and CMake build directory
@luncliff luncliff changed the title Create files and CMake option to support vcpkg Create CMake option onnxruntime_USE_VCPKG Jul 24, 2024
* CUDA build will be tried next time...
* Remove onnxruntime_vcpkg_deps.cmake
@luncliff luncliff marked this pull request as ready for review July 24, 2024 17:56
@luncliff luncliff requested a review from a team as a code owner July 24, 2024 17:56
@luncliff
Copy link
Contributor Author

Updated note and title.

Dropped CUDA feature support in this PR.
I felt like making too huge changes here. I would make another PR for other features

* add dropped changes
@snnn
Copy link
Member

snnn commented Jul 24, 2024

/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline

@snnn
Copy link
Member

snnn commented Jul 24, 2024

/azp run Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed

Copy link

Azure Pipelines successfully started running 9 pipeline(s).

1 similar comment
Copy link

Azure Pipelines successfully started running 9 pipeline(s).

@snnn
Copy link
Member

snnn commented Jul 24, 2024

We probably need to wait for the next absl release.

@luncliff
Copy link
Contributor Author

absl::demangle_rust was not intended one. I saw absl::demangle_internal in my fork, but not the one in the log. I will check again

@luncliff luncliff marked this pull request as draft July 24, 2024 18:37
@snnn
Copy link
Member

snnn commented Aug 15, 2024

/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline

@snnn
Copy link
Member

snnn commented Aug 15, 2024

/azp run Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed

Copy link

Azure Pipelines successfully started running 9 pipeline(s).

Copy link

Azure Pipelines successfully started running 8 pipeline(s).

@luncliff
Copy link
Contributor Author

luncliff commented Sep 6, 2024

Hi, is there a plan for this PR?
I'm going to restart discussion in vcpkg, so it will be helpful if I know the milestone of the project.

Any feedback will be welcomed. Thanks 😊

@snnn
Copy link
Member

snnn commented Sep 9, 2024

Sorry I was on vacation last month. Just came back.

@luncliff
Copy link
Contributor Author

luncliff commented Sep 9, 2024 via email

* cmake: use eigen from FetchContent
* ONNX will be used with FetchContent
  Current vcpkg upstream doesn't support onnx 1.16.0+.
  Here, we will mix FetchContent and vcpkg-supported find_package
@snnn
Copy link
Member

snnn commented Sep 10, 2024

/azp run Big Models, Linux Android Emulator QNN CI Pipeline, Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline

@snnn
Copy link
Member

snnn commented Sep 10, 2024

/azp run Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CUDA CI Pipeline

1 similar comment
@snnn
Copy link
Member

snnn commented Sep 10, 2024

/azp run Linux OpenVINO CI Pipeline, Linux QNN CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, Windows ARM64 QNN CI Pipeline, Windows CPU CI Pipeline, Windows GPU CUDA CI Pipeline

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Copy link

Azure Pipelines successfully started running 7 pipeline(s).

1 similar comment
Copy link

Azure Pipelines successfully started running 7 pipeline(s).

@snnn
Copy link
Member

snnn commented Sep 10, 2024

/azp run Windows GPU DML CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows x64 QNN CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline

Copy link

Azure Pipelines successfully started running 7 pipeline(s).

@snnn snnn merged commit f633caa into microsoft:main Sep 10, 2024
71 checks passed
@snnn
Copy link
Member

snnn commented Sep 10, 2024

Thank you!

@luncliff
Copy link
Contributor Author

Thank you, @snnn. I will submit another PR if microsoft/vcpkg needs it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants