Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →ONNX Runtime inference skill covering PyTorch, TensorFlow, and scikit-learn model conversion, GPU/CPU execution, and quantization.
Use this skill ↓95% 95%0 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 21 of 22 without it.
3 of 3 safety checks passed
ONNX Runtime is a cross-platform ML inference engine that runs models in the ONNX format. Supports CPU, GPU (CUDA, DirectML), and mobile inference with graph optimizations, quantization, and custom operators.
uv pip install onnxruntime # CPU
uv pip install onnxruntime-gpu # CUDA
# Convert first: from transformers, PyTorch, etc.
import onnxruntime as ort
import numpy as np
session = ort.InferenceSession("model.onnx")
input_name = session.get_inputs()[0].name
output_name = session.get_outputs()[0].name
result = session.run([output_name], {input_name: np.random.randn(1, 3, 224, 224).astype(np.float32)})
print(result[0].shape)
# GPU inference
session = ort.InferenceSession("model.onnx", providers=["CUDAExecutionProvider"])
# Enable optimizations
options = ort.SessionOptions()
options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
session = ort.InferenceSession("model.onnx", sess_options=options)
Next to this one in the catalogue, plus more from the same author.