Skip to main content

ONNX Runtime Python bindings

Project description

ONNX Runtime enables high-performance evaluation of trained machine learning (ML) models while keeping resource usage low. Building on Microsoft’s dedication to the Open Neural Network Exchange (ONNX) community, it supports traditional ML models as well as Deep Learning algorithms in the ONNX-ML format. Documentation is available at Python Bindings for ONNX Runtime.

Example

The following example demonstrates an end-to-end example in a very common scenario. A model is trained with scikit-learn but it has to run very fast in a optimized environment. The model is then converted into ONNX format and ONNX Runtime replaces scikit-learn to compute the predictions.

# Train a model.
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
iris = load_iris()
X, y = iris.data, iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y)
clr = RandomForestClassifier()
clr.fit(X_train, y_train)

# Convert into ONNX format with onnxmltools
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
initial_type = [('float_input', FloatTensorType([1, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)
with open("rf_iris.onnx", "wb") as f:
    f.write(onx.SerializeToString())

# Compute the prediction with ONNX Runtime
import onnxruntime as rt
import numpy
sess = rt.InferenceSession("rf_iris.onnx")
input_name = sess.get_inputs()[0].name
label_name = sess.get_outputs()[0].name
pred_onx = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0]

Changes

0.2.1

C-API, Linux support for Dotnet Nuget package, Cuda 10.0 support (patch to 0.2.0).

0.2.0

C-API, Linux support for Dotnet Nuget package, Cuda 10.0 support

0.1.5

GA release as part of open sourcing onnxruntime (patch to 0.1.4).

0.1.4

GA release as part of open sourcing onnxruntime.

0.1.3

Fixes a crash on machines which do not support AVX instructions.

0.1.2

First release on Ubuntu 16.04 for CPU and GPU with Cuda 9.1 and Cudnn 7.0, supports runtime for deep learning models architecture such as AlexNet, ResNet, XCeption, VGG, Inception, DenseNet, standard linear learner, standard ensemble learners, and transform scaler, imputer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

onnxruntime-0.2.1-cp37-cp37m-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.7m Windows x86-64

onnxruntime-0.2.1-cp37-cp37m-manylinux1_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.7m

onnxruntime-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.7m macOS 10.7+ x86-64

onnxruntime-0.2.1-cp36-cp36m-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.6m Windows x86-64

onnxruntime-0.2.1-cp36-cp36m-manylinux1_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.6m

onnxruntime-0.2.1-cp36-cp36m-macosx_10_7_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

onnxruntime-0.2.1-cp35-cp35m-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.5m Windows x86-64

onnxruntime-0.2.1-cp35-cp35m-manylinux1_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.5m

onnxruntime-0.2.1-cp35-cp35m-macosx_10_6_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.5m macOS 10.6+ x86-64

File details

Details for the file onnxruntime-0.2.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3d0d588414d4859c63b1c41fac5a56e771f6f4cff0ecece7edb851fe73123b7e
MD5 c50ad76e0a0da54a783050e6bb8bdd40
BLAKE2b-256 c34967875e00676e89020e9060803e0f8da3b96cf5339608571986deed719de1

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f3f1f1185c53a9ea92c10f8bc8ddce6a61dbd9e07fb645cf01c214dc0b4835b6
MD5 4bd66a6538e00177c12afea3d4d54456
BLAKE2b-256 066e353fc650b3d0fe654ad6e8c4d97251dfb565f64c329463f10e89e92becc9

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c5b8da43b0f197318714f4900fbd37bdb06e17440928a6ef3d3961eb485b0e3e
MD5 19f016c572e70ee59bc45ead8a9b1a41
BLAKE2b-256 ecfede7d4143a5921a722aede2cb5c94ad31027d53a88e3de81f9432877d22f9

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7210b84262a59e354e9feb488f771d6275199907e55687779b6a7d3329b30818
MD5 68891b7d7dafcd69e815b349d8d8ef38
BLAKE2b-256 63aa3b611415e3cc713eda51008b241680eb6902243d4f7a82b60ae9c1f1e41a

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6abe49111d4ddb1ca37e6c4664ada378b89b4de67a802c9acffcf2b8182f0fc5
MD5 06b52ff20b50c95709ccaf96c9730f5d
BLAKE2b-256 742add3cc993dfc41143ea382b43488eab927b71eff2f44e90ada32db9c0a54e

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 cedf9ac8a7992b80af60e214053abe9329a9f1dce45af23cc6763a94e14cfbbf
MD5 1832b1fa495445616152a625334db026
BLAKE2b-256 046bbb0c4a5d44e41ebffafaf2c80ca5bbe0f2beb0a99df8b08b30346fa9d692

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 928cbecdded21706f6e482a1e0602a173245ea52da1d4968fdc8e1df2b7a2ee9
MD5 6f5058e956f4b50042d0b89223a44637
BLAKE2b-256 a3095def0d4a0433571c405582d20c3030db86a11cf7f31cd1402efc459b9a99

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 075461b99be5f9cf8f2352345cf53c68e72cb2a7403ff65bd3c4c61a298a147f
MD5 af5c67d6bc2b441685882519a245b5e8
BLAKE2b-256 158496254f8f1ab5f353efc3a57732707bbf459fefdcd49b2eb54c68b9422297

See more details on using hashes here.

File details

Details for the file onnxruntime-0.2.1-cp35-cp35m-macosx_10_6_x86_64.whl.

File metadata

  • Download URL: onnxruntime-0.2.1-cp35-cp35m-macosx_10_6_x86_64.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: CPython 3.5m, macOS 10.6+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.6

File hashes

Hashes for onnxruntime-0.2.1-cp35-cp35m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 dc1d1c8496e70266318ca508d2d84d38de58f5217d05a2438a1317de370f269f
MD5 16ddc368ab3e68bdf81481503d0f3d5b
BLAKE2b-256 36943865f9e0bed21daa973fa4ac116313850d22fad49d6453b3c30de682d01d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page