{"id":24722,"library":"torch-ort","title":"Torch-ORT","description":"torch-ort accelerates PyTorch models using ONNX Runtime. Version 1.19.2 supports PyTorch 2.x and ONNX Runtime 1.19.x. Released monthly in sync with ONNX Runtime.","status":"active","version":"1.19.2","language":"python","source_language":"en","source_url":"https://github.com/pytorch/ort","tags":["pytorch","onnx-runtime","acceleration","inference","training"],"install":[{"cmd":"pip install torch-ort","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required for model export and execution.","package":"torch","optional":false},{"reason":"Runtime for executing ONNX models.","package":"onnxruntime","optional":false}],"imports":[{"note":"Common alias is not needed; just use ORTModule directly.","wrong":"from torch_ort import ORTModule as ORT","symbol":"ORTModule","correct":"from torch_ort import ORTModule"},{"note":"Function name changed in v1.10.0.","wrong":"from torch_ort import ort_enable_training","symbol":"enable_training","correct":"from torch_ort import enable_training"}],"quickstart":{"code":"import torch\nfrom torch_ort import ORTModule\n\nmodel = torch.nn.Linear(10, 5)\nort_model = ORTModule(model)\n\nx = torch.randn(3, 10)\noutput = ort_model(x)\nprint(output)","lang":"python","description":"Wrap a PyTorch model with ORTModule to accelerate inference/training via ONNX Runtime."},"warnings":[{"fix":"Upgrade onnxruntime to 1.14+ or pin torch-ort to <1.14.0.","message":"Breaking change: torch-ort v1.14+ requires ONNX Runtime 1.14+. Older ONNX Runtime installations will cause import errors.","severity":"breaking","affected_versions":">=1.14.0"},{"fix":"Remove calls to enable_training; ORTModule now auto-detects training vs inference.","message":"The 'enable_training' function is deprecated since v1.15.0. Training mode is automatically detected.","severity":"deprecated","affected_versions":">=1.15.0"},{"fix":"Test model with ORTModule and fallback to native PyTorch if unsupported ops are encountered. Use ort_model.debug() to trace unsupported operators.","message":"ORTModule does not support all PyTorch operations. Custom autograd.Function subclasses may fail silently.","severity":"gotcha","affected_versions":"all"},{"fix":"Convert model _before_ training or after final eval to avoid key mismatch. Use model.load_state_dict on the original model, not the ORTModule-wrapped one.","message":"Models must be in eval mode before conversion? No, ORTModule works in both train and eval, but state dict keys may change if you convert mid-training.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install onnxruntime","cause":"onnxruntime is not installed.","error":"ModuleNotFoundError: No module named 'onnxruntime'"},{"fix":"Replace or reimplement the unsupported operator using supported ops. Check the list at https://pytorch.org/docs/stable/onnx.html","cause":"A PyTorch operator used in the model is not yet supported by ONNX export.","error":"RuntimeError: Exporting the operator ... to ONNX is not supported."},{"fix":"Upgrade torch-ort to the latest version: pip install --upgrade torch-ort","cause":"Using a very old version of torch-ort (pre-1.0) where ORTModule was named differently.","error":"AttributeError: module 'torch_ort' has no attribute 'ORTModule'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}