microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.83k stars 2.94k forks source link

[Build] No C++ library is generated after compilation completed #16610

Open LiuPeiqiCN opened 1 year ago

LiuPeiqiCN commented 1 year ago

Describe the issue

After compilation completed, I only found python whl and C# nuget package, but I canot found c++ library just like:

Urgency

No response

Target platform

Windows 11

Build script

.\build.bat --config Release --build_shared_lib --parallel --build --build_nuget --build_wheel --skip_tests --skip_onnx_tests --skip_winml_tests --skip_nodejs_tests --use_dnnl --use_dml --use_xnnpack --use_cuda --cuda_home "D:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" --cudnn_home "D:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" --cuda_version=11.8 --use_tensorrt --tensorrt_home "D:/vcpkgs/TensorRT/TensorRT-8.6.1.6" --use_openvino HETERO:GPU,CPU --use_azure --cmake_extra_defines BUILD_TESTING=OFF CMAKE_INSTALL_PREFIX="install" InferenceEngine_DIR="D:\vcpkgs\openvino\windows_2023.0.1.11005\runtime\cmake" ngraph_DIR="D:\vcpkgs\openvino\windows_2023.0.1.11005\runtime\cmake" onnxruntime_BUILD_UNIT_TESTS=OFF --cmake_generator "Visual Studio 17 2022" --update

Error / output

-

Visual Studio Version

VS2022

GCC / Compiler Version

No response

mszhanyi commented 1 year ago

could you check if the sln file is generated correctly in {root of source}\build\Windows ?

LiuPeiqiCN commented 1 year ago

Yes, .sln file is generated correctly and I can build ONNXRuntime successful. It seems that ONNXRuntime only generates the lib files in src\build\Windows\Release, but it does not perform the installation action for the c++ package. If I manually open the .sln file and execute the Install project, there will be a lot of missing files in the generated bin/include/lib folders. Furthermore, even if I integrate CUDA/TensorRT/OpenVINO/DML/DNNL, the generated C# NuGet package only supports OpenVINO and lacks the relevant files for CUDA/TensorRT...

snnn commented 1 year ago

There is no formal installation step. ONNX Runtime is a library. To use it, you need:

  1. onnxruntime_c_api.h and its dependencies
  2. The DLLs generated from your build, mainly onnxruntime.dll
  3. The import libs of the DLLs

You can copy out the files to somewhere then start to use them. You can also get a packed zip file from https://github.com/microsoft/onnxruntime/releases, then unzip it you will know what files from your build are necessary.

SolomidHero commented 1 year ago

Hi @snnn I tried to get files using cmake --install <> command, but files installed seems not complete with what i find in release packages (https://github.com/microsoft/onnxruntime/releases). Here what I tried for build:

.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --use_mimalloc --update --build --cmake_generator "Visual Studio 17 2022"

cd build\Windows\RelWithDebInfo
cmake --install . --config RelWithDebInfo

And I got plenty of files in program files:

What have been created in 'C:\Program Files\onnxruntime\include' ``` ls 'C:\Program Files\onnxruntime\include' -Recurse -Filter "*.h" Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\common Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 367 basic_types.h -a---- 10/11/2023 5:59 PM 1957 code_location.h -a---- 10/11/2023 5:59 PM 13555 common.h -a---- 10/11/2023 5:59 PM 2952 const_pointer_container.h -a---- 10/11/2023 5:59 PM 370 denormal.h -a---- 10/11/2023 5:59 PM 2775 eigen_common_wrapper.h -a---- 10/11/2023 5:59 PM 2451 exceptions.h -a---- 10/11/2023 5:59 PM 18017 gpu_profiler_common.h -a---- 10/11/2023 5:59 PM 136 gsl.h -a---- 10/11/2023 5:59 PM 810 hash_combine.h -a---- 10/11/2023 5:59 PM 6691 inlined_containers.h -a---- 10/11/2023 5:59 PM 5996 inlined_containers_fwd.h -a---- 10/11/2023 5:59 PM 4357 make_string.h -a---- 10/11/2023 5:59 PM 2699 narrow.h -a---- 10/11/2023 5:59 PM 410 optional.h -a---- 10/11/2023 5:59 PM 2129 parse_string.h -a---- 10/11/2023 5:59 PM 2903 profiler_common.h -a---- 10/11/2023 5:59 PM 2959 span_utils.h -a---- 10/11/2023 5:59 PM 482 spin_pause.h -a---- 10/11/2023 5:59 PM 5339 status.h -a---- 10/11/2023 5:59 PM 299 string_helper.h Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\common\logging Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 3341 capture.h -a---- 10/11/2023 5:59 PM 1110 isink.h -a---- 10/11/2023 5:59 PM 12621 logging.h -a---- 10/11/2023 5:59 PM 14611 macros.h -a---- 10/11/2023 5:59 PM 708 severity.h Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\framework Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 8452 allocator.h -a---- 10/11/2023 5:59 PM 1465 alloc_kind.h -a---- 10/11/2023 5:59 PM 1185 buffer_deleter.h -a---- 10/11/2023 5:59 PM 1961 customregistry.h -a---- 10/11/2023 5:59 PM 35373 data_types.h -a---- 10/11/2023 5:59 PM 24878 data_types_internal.h -a---- 10/11/2023 5:59 PM 726 endian.h -a---- 10/11/2023 5:59 PM 15317 execution_provider.h -a---- 10/11/2023 5:59 PM 5027 float16.h -a---- 10/11/2023 5:59 PM 594 framework_common.h -a---- 10/11/2023 5:59 PM 265 framework_provider_common.h -a---- 10/11/2023 5:59 PM 1073 func_api.h -a---- 10/11/2023 5:59 PM 12148 kernel_def_builder.h -a---- 10/11/2023 5:59 PM 5911 kernel_registry.h -a---- 10/11/2023 5:59 PM 23704 op_kernel.h -a---- 10/11/2023 5:59 PM 8300 op_kernel_context.h -a---- 10/11/2023 5:59 PM 2425 op_kernel_info.h -a---- 10/11/2023 5:59 PM 6052 op_node_proto_helper.h -a---- 10/11/2023 5:59 PM 2710 ortdevice.h -a---- 10/11/2023 5:59 PM 2715 ortmemoryinfo.h -a---- 10/11/2023 5:59 PM 3994 ort_value.h -a---- 10/11/2023 5:59 PM 498 provider_options.h -a---- 10/11/2023 5:59 PM 5468 provider_options_utils.h -a---- 10/11/2023 5:59 PM 175 provider_shutdown.h -a---- 10/11/2023 5:59 PM 1931 run_options.h -a---- 10/11/2023 5:59 PM 23925 sparse_tensor.h -a---- 10/11/2023 5:59 PM 7804 stream_handles.h -a---- 10/11/2023 5:59 PM 11673 tensor.h -a---- 10/11/2023 5:59 PM 6875 tensor_shape.h -a---- 10/11/2023 5:59 PM 2788 to_tensor_proto_element_type.h Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\graph Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 1834 basic_types.h -a---- 10/11/2023 5:59 PM 3108 constants.h -a---- 10/11/2023 5:59 PM 708 function.h -a---- 10/11/2023 5:59 PM 74878 graph.h -a---- 10/11/2023 5:59 PM 6762 graph_nodes.h -a---- 10/11/2023 5:59 PM 8799 graph_viewer.h -a---- 10/11/2023 5:59 PM 3465 indexed_sub_graph.h -a---- 10/11/2023 5:59 PM 5905 node_arg.h -a---- 10/11/2023 5:59 PM 6468 schema_registry.h Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\optimizer Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 3583 graph_transformer.h -a---- 10/11/2023 5:59 PM 3592 graph_transformer_config.h -a---- 10/11/2023 5:59 PM 562 graph_transformer_level.h -a---- 10/11/2023 5:59 PM 4075 graph_transformer_utils.h -a---- 10/11/2023 5:59 PM 4978 rewrite_rule.h -a---- 10/11/2023 5:59 PM 4189 rule_based_graph_transformer.h Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\providers\cpu Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 416 cpu_provider_factory.h Directory: C:\Program Files\onnxruntime\include\onnxruntime\core\session Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 10/11/2023 5:59 PM 3728 environment.h -a---- 10/11/2023 5:59 PM 3085 experimental_onnxruntime_cxx_api.h -a---- 10/11/2023 5:59 PM 4974 experimental_onnxruntime_cxx_inline.h -a---- 10/11/2023 5:59 PM 101230 onnxruntime_cxx_api.h -a---- 10/11/2023 5:59 PM 76516 onnxruntime_cxx_inline.h -a---- 10/11/2023 5:59 PM 189867 onnxruntime_c_api.h -a---- 10/11/2023 5:59 PM 1654 onnxruntime_run_options_config_keys.h -a---- 10/11/2023 5:59 PM 13270 onnxruntime_session_options_config_keys.h ```

But comparing to what inside onnxruntime-win-x64-1.15.1.zip I understand that some files are missing. For example, cmake/, include/onnxruntime_cxx_api.h etc.

What inside `onnxruntime-win-x64-1.15.1.zip` ``` Get-ChildItem .\_deps\onnxruntime-src\ -Recurse Directory: C:\Users\Administrator\DesktopAppBackend\build\_deps\onnxruntime-src Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 9/12/2023 5:51 PM include d----- 9/12/2023 5:51 PM lib -a---- 9/12/2023 5:51 PM 514 CodeSignSummary-7621b17c-3bd6-4e6d-bbbd-6cf75a0d499e.md -a---- 9/12/2023 5:51 PM 43 GIT_COMMIT_ID -a---- 9/12/2023 5:51 PM 1094 LICENSE -a---- 9/12/2023 5:51 PM 2490 Privacy.md -a---- 9/12/2023 5:51 PM 6750 README.md -a---- 9/12/2023 5:51 PM 305548 ThirdPartyNotices.txt -a---- 9/12/2023 5:51 PM 8 VERSION_NUMBER Directory: C:\Users\Administrator\DesktopAppBackend\build\_deps\onnxruntime-src\include Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 9/12/2023 5:51 PM 416 cpu_provider_factory.h -a---- 9/12/2023 5:51 PM 89672 onnxruntime_cxx_api.h -a---- 9/12/2023 5:51 PM 70212 onnxruntime_cxx_inline.h -a---- 9/12/2023 5:51 PM 174372 onnxruntime_c_api.h -a---- 9/12/2023 5:51 PM 1654 onnxruntime_run_options_config_keys.h -a---- 9/12/2023 5:51 PM 12398 onnxruntime_session_options_config_keys.h -a---- 9/12/2023 5:51 PM 498 provider_options.h -a---- 9/12/2023 5:51 PM 327 tensorrt_provider_factory.h Directory: C:\Users\Administrator\DesktopAppBackend\build\_deps\onnxruntime-src\lib Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 9/12/2023 5:51 PM 9271704 onnxruntime.dll -a---- 9/12/2023 5:51 PM 2124 onnxruntime.lib -a---- 9/12/2023 5:51 PM 216674304 onnxruntime.pdb -a---- 9/12/2023 5:51 PM 22424 onnxruntime_providers_shared.dll -a---- 9/12/2023 5:51 PM 2314 onnxruntime_providers_shared.lib -a---- 9/12/2023 5:51 PM 389120 onnxruntime_providers_shared.pdb ```

So adding to original question: How to pack build into package with all needed files like packages in releases page?

p.s. I tried to find more info in ci pipelines, but couldn't understand what option could affect behaviour in this script https://github.com/microsoft/onnxruntime/blob/main/tools/ci_build/build.py

snnn commented 10 months ago

Here is the script: https://github.com/microsoft/onnxruntime/blob/main/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml