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

[onnx,onnxruntime] new port for v1.18.0 with onnx 1.16.0 #36850

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

luncliff
Copy link
Contributor

@luncliff luncliff commented Feb 19, 2024

Notes

With my experience in the registry, Some features may not work well with toolchain.

Suggestions from the comments.

  • Generate *targets.cmake in static builc
  • find_dependency for the vcpkg ports

Hope more feature contributions after this work.

References

ONNXRuntime

microsoft/vcpkg

luncliff/vcpkg-registry

Checklist

  • Changes comply with the maintainer guide.
  • The name of the port matches an existing name for this component on https://repology.org/ if possible, and/or is strongly associated with that component on search engines.
  • Optional dependencies are resolved in exactly one way. For example, if the component is built with CMake, all find_package calls are REQUIRED, are satisfied by vcpkg.json's declared dependencies, or disabled with CMAKE_DISABLE_FIND_PACKAGE_Xxx.
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is accurate. See adding-usage for context.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is in the new port's versions file.
  • Only one version is added to each modified port's versions file.

@luncliff luncliff marked this pull request as draft February 19, 2024 10:27
ports/onnxruntime/fix-cmake.patch Outdated Show resolved Hide resolved
ports/onnxruntime/fix-cmake.patch Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
@jimwang118 jimwang118 added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Feb 20, 2024
@luncliff
Copy link
Contributor Author

Hmm.. for some reason CMake tries old version of Xcode ...

[1/2] "/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake" -E chdir "../../arm64-osx-dbg" "/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake" "/Users/vcpkg/Data/b/onnxruntime/src/v1.17.0-ab094f3828.clean/cmake" "-G" "Xcode" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=/Users/vcpkg/Data/p/onnxruntime_arm64-osx/debug" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-Donnxruntime_ENABLE_PYTHON=OFF" "-Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF" "-Donnxruntime_ENABLE_TRAINING=OFF" "-Donnxruntime_ENABLE_TRAINING_APIS=OFF" "-Donnxruntime_USE_CUDA=OFF" "-Donnxruntime_USE_CUDA_NHWC_OPS=OFF" "-Donnxruntime_USE_OPENVINO=OFF" "-Donnxruntime_USE_TENSORRT=OFF" "-Donnxruntime_USE_TENSORRT_BUILTIN_PARSER=OFF" "-Donnxruntime_USE_DML=OFF" "-Donnxruntime_USE_CUSTOM_DIRECTML=OFF" "-Donnxruntime_USE_WINML=OFF" "-Donnxruntime_USE_COREML=OFF" "-Donnxruntime_USE_MIMALLOC=OFF" "-Donnxruntime_USE_VALGRIND=OFF" "-Donnxruntime_USE_XNNPACK=OFF" "-Donnxruntime_USE_NNAPI_BUILTIN=OFF" "-Donnxruntime_USE_AZURE=OFF" "-Donnxruntime_USE_LLVM=OFF" "-Donnxruntime_BUILD_UNIT_TESTS=OFF" "-Donnxruntime_BUILD_BENCHMARKS=OFF" "-Donnxruntime_RUN_ONNX_TESTS=OFF" "-Donnxruntime_BUILD_APPLE_FRAMEWORK=OFF" "-Donnxruntime_BUILD_OBJC=OFF" "-Donnxruntime_USE_NCCL=OFF" "-Donnxruntime_USE_MPI=OFF" "-Donnxruntime_ORT_MINIMAL_BUILD=OFF" "-Donnxruntime_DISABLE_ABSEIL=ON" "-Donnxruntime_USE_MEMORY_EFFICIENT_ATTENTION=ON" "-DPython_EXECUTABLE:FILEPATH=/opt/homebrew/bin/python3" "-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=/Users/vcpkg/Data/installed/arm64-osx/tools/protobuf/protoc" "-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON" "-DBUILD_PKGCONFIG_FILES=0" "-Donnxruntime_BUILD_SHARED_LIB=0" "-Donnxruntime_BUILD_WEBASSEMBLY=OFF" "-Donnxruntime_CROSS_COMPILING=0" "-Donnxruntime_USE_FULL_PROTOBUF=OFF" "-Donnxruntime_USE_PREINSTALLED_EIGEN=ON" "-Donnxruntime_USE_EXTENSIONS=OFF" "-Donnxruntime_USE_NNAPI_BUILTIN=" "-Donnxruntime_ENABLE_CPUINFO=ON" "-Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF" "-Donnxruntime_ENABLE_BITCODE=" "-Donnxruntime_ENABLE_PYTHON=OFF" "-Donnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS=OFF" "-Donnxruntime_ENABLE_LAZY_TENSOR=OFF" "-Donnxruntime_NVCC_THREADS=1" "-Donnxruntime_DISABLE_RTTI=OFF" "-Donnxruntime_USE_NEURAL_SPEED=OFF" "-DUSE_NEURAL_SPEED=OFF" "-DORT_GIT_COMMIT:STRING="v1.17.0"" "-DORT_GIT_BRANCH:STRING="v1.17.0"" "-DCMAKE_SYSTEM_NAME=Darwin" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/Users/vcpkg/Data/work/1/s/scripts/toolchains/osx.cmake" "-DVCPKG_TARGET_TRIPLET=arm64-osx" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=/Users/vcpkg/Data/work/1/s/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=arm64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=/Users/vcpkg/Data/work/1/s" "-D_VCPKG_INSTALLED_DIR=/Users/vcpkg/Data/installed" "-DVCPKG_MANIFEST_INSTALL=OFF" "-DCMAKE_OSX_ARCHITECTURES=arm64" "-Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF" "-Donnxruntime_ENABLE_MEMORY_PROFILE=OFF" "-Donnxruntime_DEBUG_NODE_INPUTS_OUTPUTS=1"
FAILED: ../../arm64-osx-dbg/CMakeCache.txt 
"/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake" -E chdir "../../arm64-osx-dbg" "/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake" "/Users/vcpkg/Data/b/onnxruntime/src/v1.17.0-ab094f3828.clean/cmake" "-G" "Xcode" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=/Users/vcpkg/Data/p/onnxruntime_arm64-osx/debug" "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" "-Donnxruntime_ENABLE_PYTHON=OFF" "-Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF" "-Donnxruntime_ENABLE_TRAINING=OFF" "-Donnxruntime_ENABLE_TRAINING_APIS=OFF" "-Donnxruntime_USE_CUDA=OFF" "-Donnxruntime_USE_CUDA_NHWC_OPS=OFF" "-Donnxruntime_USE_OPENVINO=OFF" "-Donnxruntime_USE_TENSORRT=OFF" "-Donnxruntime_USE_TENSORRT_BUILTIN_PARSER=OFF" "-Donnxruntime_USE_DML=OFF" "-Donnxruntime_USE_CUSTOM_DIRECTML=OFF" "-Donnxruntime_USE_WINML=OFF" "-Donnxruntime_USE_COREML=OFF" "-Donnxruntime_USE_MIMALLOC=OFF" "-Donnxruntime_USE_VALGRIND=OFF" "-Donnxruntime_USE_XNNPACK=OFF" "-Donnxruntime_USE_NNAPI_BUILTIN=OFF" "-Donnxruntime_USE_AZURE=OFF" "-Donnxruntime_USE_LLVM=OFF" "-Donnxruntime_BUILD_UNIT_TESTS=OFF" "-Donnxruntime_BUILD_BENCHMARKS=OFF" "-Donnxruntime_RUN_ONNX_TESTS=OFF" "-Donnxruntime_BUILD_APPLE_FRAMEWORK=OFF" "-Donnxruntime_BUILD_OBJC=OFF" "-Donnxruntime_USE_NCCL=OFF" "-Donnxruntime_USE_MPI=OFF" "-Donnxruntime_ORT_MINIMAL_BUILD=OFF" "-Donnxruntime_DISABLE_ABSEIL=ON" "-Donnxruntime_USE_MEMORY_EFFICIENT_ATTENTION=ON" "-DPython_EXECUTABLE:FILEPATH=/opt/homebrew/bin/python3" "-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=/Users/vcpkg/Data/installed/arm64-osx/tools/protobuf/protoc" "-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON" "-DBUILD_PKGCONFIG_FILES=0" "-Donnxruntime_BUILD_SHARED_LIB=0" "-Donnxruntime_BUILD_WEBASSEMBLY=OFF" "-Donnxruntime_CROSS_COMPILING=0" "-Donnxruntime_USE_FULL_PROTOBUF=OFF" "-Donnxruntime_USE_PREINSTALLED_EIGEN=ON" "-Donnxruntime_USE_EXTENSIONS=OFF" "-Donnxruntime_USE_NNAPI_BUILTIN=" "-Donnxruntime_ENABLE_CPUINFO=ON" "-Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF" "-Donnxruntime_ENABLE_BITCODE=" "-Donnxruntime_ENABLE_PYTHON=OFF" "-Donnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS=OFF" "-Donnxruntime_ENABLE_LAZY_TENSOR=OFF" "-Donnxruntime_NVCC_THREADS=1" "-Donnxruntime_DISABLE_RTTI=OFF" "-Donnxruntime_USE_NEURAL_SPEED=OFF" "-DUSE_NEURAL_SPEED=OFF" "-DORT_GIT_COMMIT:STRING="v1.17.0"" "-DORT_GIT_BRANCH:STRING="v1.17.0"" "-DCMAKE_SYSTEM_NAME=Darwin" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/Users/vcpkg/Data/work/1/s/scripts/toolchains/osx.cmake" "-DVCPKG_TARGET_TRIPLET=arm64-osx" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=external" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=/Users/vcpkg/Data/work/1/s/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=dynamic" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=arm64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=/Users/vcpkg/Data/work/1/s" "-D_VCPKG_INSTALLED_DIR=/Users/vcpkg/Data/installed" "-DVCPKG_MANIFEST_INSTALL=OFF" "-DCMAKE_OSX_ARCHITECTURES=arm64" "-Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF" "-Donnxruntime_ENABLE_MEMORY_PROFILE=OFF" "-Donnxruntime_DEBUG_NODE_INPUTS_OUTPUTS=1"
CMake Error:
  Xcode 1.5 not supported.


CMake Error: Could not create named generator Xcode

Generators
* Unix Makefiles               = Generates standard UNIX makefiles.

@luncliff luncliff marked this pull request as ready for review February 20, 2024 10:43
@dg0yt
Copy link
Contributor

dg0yt commented Feb 20, 2024

IIRC the xcode generator needs a GUI session, i.e. doesn't work in CI.

@luncliff
Copy link
Contributor Author

Added notes for the current features.
If the PR is labeled with requires:all-feature-testing vcpkg install port[all features supported by that port] needs to be demonstrated to function ,
I will change it to draft and then add more ports to the upstream.

@jimwang118 jimwang118 marked this pull request as draft February 21, 2024 02:34
@luncliff
Copy link
Contributor Author

Can't fix the errors of the CUDA code. I will remove cuda and xnnpack feature for this work.
I think I can support them in next port-version...

@luncliff
Copy link
Contributor Author

luncliff commented Mar 2, 2024

So the build error comes from arm_neon build.

  • Reproduced in NDK 25.2.9519653
  • NOT reproduced in NDK 26.2.11394342

Let me check the details...

ports/onnxruntime/fix-cmake.patch Outdated Show resolved Hide resolved
ports/onnxruntime/onnxruntime_vcpkg_deps.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/vcpkg.json Outdated Show resolved Hide resolved
ports/onnxruntime/vcpkg.json Outdated Show resolved Hide resolved
@luncliff
Copy link
Contributor Author

So the build error comes from arm_neon build.

  • Reproduced in NDK 25.2.9519653
  • NOT reproduced in NDK 26.2.11394342

Let me check the details...

For NDK 25(Clang 14.0.7), I tried -march=armv8.2-a+bf16 and -march=armv8.2-a+fp16 compiler option but didn't work.
I think I haver to wait NDK 26 for Android...

@luncliff luncliff marked this pull request as ready for review March 12, 2024 13:46
ports/onnxruntime/vcpkg.json Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/onnxruntime_vcpkg_deps.cmake Outdated Show resolved Hide resolved
@luncliff luncliff marked this pull request as draft April 1, 2024 04:20
@luncliff luncliff marked this pull request as ready for review April 15, 2024 03:40
@luncliff luncliff marked this pull request as draft April 15, 2024 03:52
@luncliff luncliff marked this pull request as ready for review April 15, 2024 11:48
@luncliff
Copy link
Contributor Author

  • 6109c62 Temporary allow failure of onnxruntime:arm64-android

Copy link
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of work! 🚀

ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
Comment on lines 139 to 142
if(("openvino" IN_LIST FEATURES) AND VCPKG_TARGET_IS_WINDOWS)
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/onnxruntime_providers_openvino.dll" "${CURRENT_PACKAGES_DIR}/debug/bin/onnxruntime_providers_openvino.dll")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/onnxruntime_providers_openvino.dll" "${CURRENT_PACKAGES_DIR}/bin/onnxruntime_providers_openvino.dll")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming after install: Expected to break exported CMake config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The installation was fixed in microsoft/onnxruntime#19966
Use the latest release to apply the patch

Comment on lines 146 to 148
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin" "${CURRENT_PACKAGES_DIR}/bin")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these dirs empty? Or are there programs which need to be handled regardless of linkage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there might some tool build based on features, but they are not defined in this port version.

ports/onnxruntime/project-config-template.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/portfile.cmake Outdated Show resolved Hide resolved
ports/onnxruntime/project-config-template.cmake Outdated Show resolved Hide resolved
@luncliff luncliff changed the title [onnxruntime] create a new port with v1.17.0 [onnxruntime] create a new port with v1.17.3 Apr 20, 2024
@JoergAtGithub JoergAtGithub mentioned this pull request May 2, 2024
11 tasks
@luncliff
Copy link
Contributor Author

luncliff commented May 7, 2024

Hi, requesting a review and a tag for it

@luncliff luncliff force-pushed the port/onnxruntime branch 2 times, most recently from d4aa6f4 to 9e67876 Compare August 25, 2024 15:07
@luncliff
Copy link
Contributor Author

luncliff commented Sep 6, 2024

Hi team. I was waiting the upstream's pull request, but seems like it's taking more time than I expected.
I just squashed changes into several commits and rebased with the master branch again.

Here is the current status of this pull request. (Just in my memory, feel free to comment more!)

Notes

Issues

As a vcpkg user and registry maintainer, I think #38879 can be closed.
We can add warning message in onnxruntime portfile so the user can be more cautious. And it will be better if we can reduce burdun of port maintenance by doing so.

Building CUDA in vcpkg CI was simple. However, installation path of TensorRT is unknown.
I made the portfile.cmake to use variable TENSORRT_ROOT, forwarding it to onnxruntime_TENSORRT_HOME CMake option.
(Maybe user can declare it in the triplet)

@luncliff luncliff marked this pull request as ready for review September 6, 2024 14:20
snnn pushed a commit to microsoft/onnxruntime that referenced this pull request Sep 10, 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`)

```cmake
# 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)
```

3. Create CMakePresets.json and presets to [run vcpkg in manifest
mode](https://learn.microsoft.com/en-us/vcpkg/concepts/manifest-mode)
   * Currently, it's NOT for training build
   * Main triplets are `x64-windows` and `x64-osx`

```pwsh
Push-Location "cmake"
    cmake --preset "x64-windows-vcpkg"
    cmake --build --preset "x64-windows-vcpkg-debug"
Pop-Location
```
```bash
pushd "cmake"
    cmake --preset "x64-osx-vcpkg"
    cmake --build --preset "x64-osx-vcpkg-debug"
popd
```

4. Updated tools/ci_build/build.py
* `--use_vcpkg` option: it needs `CMAKE_TOOLCHAIN_FILE` with
[vcpkg.cmake toolchain
script](https://github.com/microsoft/vcpkg/blob/master/scripts/buildsystems/vcpkg.cmake)
* `--compile_no_warning_as_error` is recommended because library version
differences will cause unexpected compiler warnings

```bash
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=..."
```

5. Created Job `Vcpkg` for Windows and macOS
   * Show how to setup and use vcpkg.  
     Similar to the CMakePresets.json usage

### Motivation and Context

* Help #7150
* Help microsoft/vcpkg#36850
   * luncliff/vcpkg-registry#212
   * microsoft/vcpkg#39881
* luncliff/vcpkg-registry#215
   * luncliff/vcpkg-registry#216
   * luncliff/vcpkg-registry#227
*
https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html
*
https://github.com/microsoft/vcpkg/blob/master/scripts/buildsystems/vcpkg.cmake

### Future Works?

More feature coverage with the vcpkg supported libraries

* CUDA feature support
* Training feature support
Comment on lines 20 to 27
# https://github.com/microsoft/onnxruntime/blob/26250ae74d2c9a3c6860625ba4a147ddfb936907/cmake/deps.txt#L20-L25
vcpkg_from_gitlab(
GITLAB_URL https://gitlab.com
OUT_SOURCE_PATH EIGEN_SOURCE_PATH
REPO libeigen/eigen
REF e7248b26a1ed53fa030c5c459f7ea095dfd276ac
SHA512 2ede6fa56b8374cd5618a9cca9f3666909255277d0fe23eb54266972a9ab4e6c8c00abcb8fab918ea45b4aec37a3d316ca01107ff082dc9f19851df58d7ac80d
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we are using a different version of eigen3.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will introduce potential dependency conflicts and https://learn.microsoft.com/en-us/vcpkg/contributing/maintainer-guide#do-not-use-vendored-dependencies

Could the required fixes be backported?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or temporarily change the port eigen3 to the commit first, and then wait for the upstream release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I can backport the related part correctly in ONNXRuntime. Either bumping eigen3 for the other ports.

In my vcpkg-registry, I can move to any commit I want, but it's different in this repository.
So I need some direction for the next move.

  • To bump eigen3, it should be done in another PR considering the work size
  • To backport eigen3, I can try, but some API might block coupled to the version and I can't make a correct change in the case

Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like the simple upgrade but upstream hasn’t released new version. You could keep this usage temporarily while fixing onnx.

If fixed version of eigen3 is still not released before merging current PR, I will need further review by the team.

Copy link
Member

@BillyONeal BillyONeal Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think vendoring a different eigen than the one selected by vcpkg is acceptable. It leads to ODR violations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comment "# This Eigen commit id matches the eigen archive being consumed from https://gitlab.com/libeigen/eigen/-/archive/3.4/eigen-3.4.zip" given that vcpkg is consuming that same thing the one in our port should have the fixes that onnxruntime needs?

Do we know of a specific change onnxruntime needs that we could backport to our port?

@dg0yt
Copy link
Contributor

dg0yt commented Sep 16, 2024

I suggested ONNXRuntime upstream to support onnxruntime_USE_VCPKG so we can inject existing ports.

I prefer to recommend upstreams to not use vcpkg-specific hacks. There is nothing special about wanting de-vendored dependencies. (vcpkg may have unofficial CMake configs, but they are unofficial to limit their proliferation.)

@luncliff
Copy link
Contributor Author

I prefer to recommend upstreams to not use vcpkg-specific hacks. There is nothing special about wanting de-vendored dependencies. (vcpkg may have unofficial CMake configs, but they are unofficial to limit their proliferation.)

Most of FetchContent and find_pacakge are integrated in upstream.
Currently, there are a few target mismatches between the source build and the vcpkg installation.
When those changes are gone, onnxruntime_USE_VCPKG can be removed and the required changes will be spread into each CMake modules in the project.

I think it's enough for now.

# # Handle copyright
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/onnxruntime-win-x64-gpu-${VERSION}/LICENSE")
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
message(WARNING "${PORT} is deprecated. Please use port onnxruntime instead.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just outright deindex it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any rules for deindexing? I simply followed the case of qt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written is OK; it's more a user experience thing. If you think there are lots of existing users of onnxruntime-gpu who would be confused by it suddenly not existing, then keeping this makes sense. That was the case with qt, in particular because vcpkg install qt is something one is likely to do.

If you think there aren't a huge number of users who would be confused by it not existing, making it not exist might be clearer for most users because they won't be shown that a port exists that they shouldn't use.

To make it not exist:

  • Revert all changes to versions/o-/onnxruntime-gpu.json
  • Delete the onnxruntime-gpu entry from versions/baseline.json
  • Delete ports/onnxruntime-gpu

Otherwise it's fine as written

@BillyONeal
Copy link
Member

@luncliff Do you want us to explicitly not take #40962 ? I agree that you're fixing more stuff in here but it isn't clear to me that blocking this 'simple version bump' is the right thing pending your other fixes here... Thanks!

@luncliff
Copy link
Contributor Author

I'm fine with #40962 and other updates of related ports. I'm checking them regularly.

I will try supporting the current eigen3 in vcpkg. Then I will move to ONNX Runtime 1.19.2.

@luncliff luncliff marked this pull request as draft September 16, 2024 21:26
@BillyONeal
Copy link
Member

I'm fine with #40962

Ok, I merged it then. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ONNX Runtime] update to v1.17.0 [New Port Request] ONNX Runtime [New Port Request] ONNX Runtime - ACL