configure onnx runtime to use the tensorrt and cuda execution providers with fallback

domain: onnxruntime.ai/docs/execution-providers · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Append execution providers to SessionOptions in priority order, e.g. OrtSessionOptionsAppendExecutionProvider_Tensorrt then _CUDA, so ONNX Runtime falls back if TensorRT can't run a given op
  2. Set TensorRT-specific options such as workspace size, and enable ORT_TENSORRT_FP16_ENABLE or ORT_TENSORRT_INT8_ENABLE if your model and hardware support reduced precision
  3. Pass per-session execution provider options rather than relying only on environment variables, since explicit session options override environment-variable settings
  4. Create the InferenceSession with the ordered provider list and confirm via session introspection which provider actually executed each node
  5. Benchmark against CUDA-only and CPU-only execution to quantify TensorRT engine-build overhead on first run versus steady-state latency

Known gotchas

Related routes

Export a PyTorch model to ONNX and run inference with ONNX Runtime
onnxruntime.ai/docs · 6 steps · unrated
Configure tensor and pipeline parallelism for multi-GPU vLLM serving
docs.vllm.ai · 5 steps · unrated
Deploy an LLM with TensorRT-LLM backend on NVIDIA Triton Inference Server
docs.nvidia.com/deeplearning/triton-inference-server · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans