--- title: Install ONNX Runtime description: Instructions to install ONNX Runtime on your target platform in your environment has_children: false nav_order: 1 redirect_from: /docs/how-to/install --- # Install ONNX Runtime (ORT) See the [installation matrix](https://onnxruntime.ai) for recommended instructions for desired combinations of target operating system, hardware, accelerator, and language. Details on OS versions, compilers, language versions, dependent libraries, etc can be found under [Compatibility](../reference/compatibility). ## Contents {: .no_toc } * TOC placeholder {:toc} ## Requirements * All builds require the English language package with `en_US.UTF-8` locale. On Linux, install [language-pack-en package](https://packages.ubuntu.com/search?keywords=language-pack-en) by running `locale-gen en_US.UTF-8` and `update-locale LANG=en_US.UTF-8` * Windows builds require [Visual C++ 2019 runtime](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads). The latest version is recommended. ## Python Installs ### Install ONNX Runtime (ORT) ```bash pip install onnxruntime ``` ```bash pip install onnxruntime-gpu ``` ### Install ONNX to export the model ```bash ## ONNX is built into PyTorch pip install torch ``` ```python ## tensorflow pip install tf2onnx ``` ```bash ## sklearn pip install skl2onnx ``` ## C#/C/C++/WinML Installs ### Install ONNX Runtime (ORT) ```bash # CPU dotnet add package Microsoft.ML.OnnxRuntime ``` ```bash # GPU dotnet add package Microsoft.ML.OnnxRuntime.Gpu ``` ```bash # DirectML dotnet add package Microsoft.ML.OnnxRuntime.DirectML ``` ```bash # WinML dotnet add package Microsoft.AI.MachineLearning ``` ## Install on web and mobile Unless stated otherwise, the installation instructions in this section refer to pre-built packages that include support for selected operators and ONNX opset versions based on the requirements of popular models. These packages may be referred to as "mobile packages". If you use mobile packages, your model must only use the supported [opsets and operators](../reference/operators/mobile_package_op_type_support_1.14.md). Another type of pre-built package has full support for all ONNX opsets and operators, at the cost of larger binary size. These packages are referred to as "full packages". If the pre-built mobile package supports your model/s but is too large, you can create a [custom build](../build/custom.md). A custom build can include just the opsets and operators in your model/s to reduce the size. If the pre-built mobile package does not include the opsets or operators in your model/s, you can either use the full package if available, or create a custom build. ### JavaScript Installs #### Install ONNX Runtime Web (browsers) ```bash # install latest release version npm install onnxruntime-web # install nightly build dev version npm install onnxruntime-web@dev ``` #### Install ONNX Runtime Node.js binding (Node.js) ```bash # install latest release version npm install onnxruntime-node ``` #### Install ONNX Runtime for React Native ```bash # install latest release version npm install onnxruntime-react-native ``` ### Install on iOS In your CocoaPods `Podfile`, add the `onnxruntime-c`, `onnxruntime-mobile-c`, `onnxruntime-objc`, or `onnxruntime-mobile-objc` pod, depending on whether you want to use a full or mobile package and which API you want to use. #### C/C++ ```ruby use_frameworks! # choose one of the two below: pod 'onnxruntime-c' # full package #pod 'onnxruntime-mobile-c' # mobile package ``` #### Objective-C ```ruby use_frameworks! # choose one of the two below: pod 'onnxruntime-objc' # full package #pod 'onnxruntime-mobile-objc' # mobile package ``` Run `pod install`. #### Custom build Refer to the instructions for creating a [custom iOS package](../build/custom.md#ios). ### Install on Android #### Java/Kotlin In your Android Studio Project, make the following changes to: 1. build.gradle (Project): ```gradle repositories { mavenCentral() } ``` 2. build.gradle (Module): ```gradle dependencies { // choose one of the two below: implementation 'com.microsoft.onnxruntime:onnxruntime-android:latest.release' // full package //implementation 'com.microsoft.onnxruntime:onnxruntime-mobile:latest.release' // mobile package } ``` #### C/C++ Download the [onnxruntime-android](https://mvnrepository.com/artifact/com.microsoft.onnxruntime/onnxruntime-android) (full package) or [onnxruntime-mobile](https://mvnrepository.com/artifact/com.microsoft.onnxruntime/onnxruntime-mobile) (mobile package) AAR hosted at MavenCentral, change the file extension from `.aar` to `.zip`, and unzip it. Include the header files from the `headers` folder, and the relevant `libonnxruntime.so` dynamic library from the `jni` folder in your NDK project. #### Custom build Refer to the instructions for creating a [custom Android package](../build/custom.md#android). ## Install for On-Device Training Unless stated otherwise, the installation instructions in this section refer to pre-built packages designed to perform on-device training. If the pre-built training package supports your model but is too large, you can create a [custom training build](../build/custom.md). ### Offline Phase - Prepare for Training ```bash pip install onnxruntime-training ``` ### Training Phase - On-Device Training
| Device | Language | PackageName | Installation Instructions |
|---|---|---|---|
| Windows | C, C++, C# | Microsoft.ML.OnnxRuntime.Training |
dotnet add package Microsoft.ML.OnnxRuntime.Training
|
| Linux | C, C++ | onnxruntime-training-linux*.tgz |
|
| Python | onnxruntime-training |
pip install onnxruntime-training
|
|
| Android | C, C++ | onnxruntime-training-android |
|
| Java/Kotlin | onnxruntime-training-android | In your Android Studio Project, make the following changes to:
|
|
| iOS | C, C++ | CocoaPods: onnxruntime-training-c |
|
| Objective-C | CocoaPods: onnxruntime-training-objc |
|