|
11 | 11 | * [Reduced Operator Kernel Build](#Reduced-Operator-Kernel-Build) |
12 | 12 | * [ONNX Runtime for Mobile Platforms](#ONNX-Runtime-for-Mobile-Platforms) |
13 | 13 | * [ONNX Runtime Server (Linux)](#Build-ONNX-Runtime-Server-on-Linux) |
| 14 | + * [Execution Provider Shared Libraries](#Execution-Provider-Shared-Libraries) |
14 | 15 | * Execution Providers |
15 | 16 | * [NVIDIA CUDA](#CUDA) |
16 | 17 | * [NVIDIA TensorRT](#TensorRT) |
@@ -59,24 +60,23 @@ Open Developer Command Prompt for Visual Studio version you are going to use. Th |
59 | 60 | The default Windows CMake Generator is Visual Studio 2017, but you can also use the newer Visual Studio 2019 by passing `--cmake_generator "Visual Studio 16 2019"` to `.\build.bat` |
60 | 61 |
|
61 | 62 |
|
62 | | -#### Linux/macOS |
| 63 | +#### Linux |
63 | 64 | ``` |
64 | 65 | ./build.sh --config RelWithDebInfo --build_shared_lib --parallel |
65 | 66 | ``` |
| 67 | + |
| 68 | + |
66 | 69 | ##### macOS |
67 | 70 | By default, ORT is configured to be built for a minimum target macOS version of 10.12. |
68 | 71 | The shared library in the release Nuget(s) and the Python wheel may be installed on macOS versions of 10.12+. |
69 | 72 |
|
70 | | -If you would like to use [Xcode](https://developer.apple.com/xcode/) to build the onnxruntime for x86_64 macOS, use |
71 | | -* With Xcode 11 |
| 73 | +If you would like to use [Xcode](https://developer.apple.com/xcode/) to build the onnxruntime for x86_64 macOS, please add the --user_xcode argument in the command line |
72 | 74 | ``` |
73 | 75 | ./build.sh --config RelWithDebInfo --build_shared_lib --parallel --use_xcode |
74 | 76 | ``` |
75 | | -* With Xcode 12 |
76 | | - ``` |
77 | | - ./build.sh --config RelWithDebInfo --build_shared_lib --parallel --use_xcode \ |
78 | | - --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=x86_64 |
79 | | - ``` |
| 77 | +While without this flag, the cmake build generator will be Unix makefile by default. |
| 78 | +Also, if you want to try cross compiling for Apple Silicon in an Intel-based MacOS machine, please add the argument --osx_arch arm64 with a cmake > 3.19, however the unit tests will be skipped due to the incompatible CPU instruction set. |
| 79 | + |
80 | 80 |
|
81 | 81 | #### Notes |
82 | 82 |
|
@@ -177,6 +177,24 @@ Nuget packages are created under <native_build_dir>\nuget-artifacts |
177 | 177 |
|
178 | 178 | --- |
179 | 179 |
|
| 180 | +## Execution Provider Shared Libraries |
| 181 | +The DNNL, TensorRT, and OpenVINO providers are built as shared libraries vs being statically linked into the main onnxruntime. This enables them to be loaded only when needed, and if the dependent libraries of the provider are not installed onnxruntime will still run fine, it just will not be able to use that provider. For non shared library providers, all dependencies of the provider must exist to load onnxruntime. |
| 182 | +
|
| 183 | +### Built files |
| 184 | +On Windows, shared provider libraries will be named 'onnxruntime_providers_\*.dll' (for example onnxruntime_providers_openvino.dll). |
| 185 | +On Unix, they will be named 'libonnxruntime_providers_\*.so' |
| 186 | +On Mac, they will be named 'libonnxruntime_providers_\*.dylib'. |
| 187 | +
|
| 188 | +There is also a shared library that shared providers depend on called onnxruntime_providers_shared (with the same naming convension applied as above). |
| 189 | +
|
| 190 | +Note: It is not recommended to put these libraries in a system location or added to a library search path (like LD_LIBRARY_PATH on Unix). If multiple versions of onnxruntime are installed on the system this can make them find the wrong libraries and lead to undefined behavior. |
| 191 | +
|
| 192 | +### Loading the shared providers |
| 193 | +Shared provider libraries are loaded by the onnxruntime code (do not load or depend on them in your client code). The API for registering shared or non shared providers is identical, the difference is that shared ones will be loaded at runtime when the provider is added to the session options (through a call like OrtSessionOptionsAppendExecutionProvider_OpenVINO or SessionOptionsAppendExecutionProvider_OpenVINO in the C API). |
| 194 | +If a shared provider library cannot be loaded (if the file doesn't exist, or its dependencies don't exist or not in the path) then an error will be returned. |
| 195 | +
|
| 196 | +The onnxruntime code will look for the provider shared libraries in the same location as the onnxruntime shared library is (or the executable statically linked to the static library version). |
| 197 | +
|
180 | 198 | ## Execution Providers |
181 | 199 |
|
182 | 200 | ### CUDA |
@@ -235,6 +253,8 @@ See more information on the TensorRT Execution Provider [here](./docs/execution_ |
235 | 253 | * The path to TensorRT installation must be provided via the `--tensorrt_home` parameter. |
236 | 254 |
|
237 | 255 | #### Build Instructions |
| 256 | +Note that TensorRT is built as a [shared provider library](#Execution-Provider-Shared-Libraries) |
| 257 | +
|
238 | 258 | ##### Windows |
239 | 259 | ``` |
240 | 260 | .\build.bat --cudnn_home <path to cuDNN home> --cuda_home <path to CUDA home> --use_tensorrt --tensorrt_home <path to TensorRT home> |
@@ -309,6 +329,8 @@ See more information on DNNL and MKL-ML [here](./docs/execution_providers/DNNL-E |
309 | 329 | #### Build Instructions |
310 | 330 | The DNNL execution provider can be built for Intel CPU or GPU. To build for Intel GPU, install [Intel SDK for OpenCL Applications](https://software.intel.com/content/www/us/en/develop/tools/opencl-sdk.html). Install the latest GPU driver - [Windows graphics driver](https://downloadcenter.intel.com/product/80939/Graphics), [Linux graphics compute runtime and OpenCL driver](https://github.com/intel/compute-runtime/releases). |
311 | 331 |
|
| 332 | +Note that DNNL is built as a [shared provider library](#Execution-Provider-Shared-Libraries) |
| 333 | +
|
312 | 334 | ##### Windows |
313 | 335 | `.\build.bat --use_dnnl` |
314 | 336 |
|
@@ -365,6 +387,8 @@ See more information on the OpenVINO Execution Provider [here](./docs/execution_ |
365 | 387 |
|
366 | 388 |
|
367 | 389 | #### Build Instructions |
| 390 | +Note that OpenVINO is built as a [shared provider library](#Execution-Provider-Shared-Libraries) |
| 391 | +
|
368 | 392 | ##### Windows |
369 | 393 | ``` |
370 | 394 | .\build.bat --config RelWithDebInfo --use_openvino <hardware_option> |
|
0 commit comments