Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

onnxruntime-server

> 编程语言
Open source

ONNX Runtime Server: The ONNX Runtime Server is a server that provides TCP and HTTP/HTTPS REST APIs for ONNX inference.

193 stars0 likes2 views
WebsiteGitHub

About

ONNX Runtime Server: The ONNX Runtime Server is a server that provides TCP and HTTP/HTTPS REST APIs for ONNX inference.

ONNX Runtime Server

  • ONNX: Open Neural Network Exchange
  • The ONNX Runtime Server is a server that provides TCP and HTTP/HTTPS REST APIs for ONNX inference.
  • ONNX Runtime Server aims to provide simple, high-performance ML inference and a good developer experience.
    • If you have exported ML models trained in various environments as ONNX files, you can provide inference APIs without writing additional code or metadata. Just place the ONNX files into the directory structure.
    • Each ONNX session, you can choose to use CPU or CUDA.
    • Analyze the input/output of ONNX models to provide type/shape information for your collaborators.
    • Built-in Swagger API documentation makes it easy for collaborators to test ML models through the API. (API example)
    • Ready-to-run Docker images. No build required.

  • Build ONNX Runtime Server
    • Requirements
      • Install ONNX Runtime
      • Install dependencies
    • Compile and Install
  • Install via a package manager
  • Run the server
  • Docker
  • API
  • How to use

Build ONNX Runtime Server

Requirements

  • ONNX Runtime
  • Boost
  • CMake, pkg-config
  • CUDA(optional, for Nvidia GPU support)
  • OpenSSL(optional, for HTTPS)

Install ONNX Runtime

Linux

  • Use download-onnxruntime-linux.sh script
    • This script downloads the latest version of the binary and install to /usr/local/onnxruntime.
    • Also, add /usr/local/onnxruntime/lib to /etc/ld.so.conf.d/onnxruntime.conf and run ldconfig.
  • Or manually download binary from ONNX Runtime Releases.

Mac OS

bash
brew install onnxruntime

Install dependencies

Ubuntu/Debian

bash
sudo apt install cmake pkg-config libboost-all-dev libssl-dev

# optional, for running tests
sudo apt install libgtest-dev
(optional) CUDA support (CUDA 12.x/13.x, cuDNN 9.x)
  • Follow the instructions below to install the CUDA Toolkit and cuDNN.
    • CUDA Toolkit Installation Guide
    • CUDA Download for Ubuntu
bash
# CUDA 12
sudo apt install cuda-toolkit-12 libcudnn9-dev-cuda-12
# CUDA 13
sudo apt install cuda-toolkit-13 libcudnn9-dev-cuda-13

# optional, for Nvidia GPU support with Docker
sudo apt install nvidia-container-toolkit

Mac OS

bash
brew install cmake boost openssl

Compile and Install

bash
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
sudo cmake --install build --prefix /usr/local/onnxruntime-server

Install via a package manager

OS Method Command
Arch Linux AUR yay -S onnxruntime-server

Run the server

  • You must enter the path option(--model-dir) where the models are located.
    • The onnx model files must be located in the following path: ${model_dir}/${model_name}/${model_version}/model.onnx or ${model_dir}/${model_name}/${model_version}.onnx

| Files in --model-dir | Create session request body | Get/Execute session API URL path

(after created) | |--------------------------------------------------------------------------|-----------------------------------------------------|-------------------------------------------------------| | model_name/model_version/model.onnx or model_name/model_version.onnx | {"model":"model_name", "version":"model_version"} | /api/sessions/model_name/model_version | | sample/v1/model.onnx or sample/v1.onnx | {"model":"sample", "version":"v1"} | /api/sessions/sample/v1 | | sample/v2/model.onnx or sample/v2.onnx | {"model":"sample", "version":"v2"} | /api/sessions/sample/v2 | | other/20200101/model.onnx or other/20200101.onnx | {"model":"other", "version":"20200101"} | /api/sessions/other/20200101 |

  • You need to enable one of the following backends: TCP, HTTP, or HTTPS.
    • If you want to use TCP, you must specify the --tcp-port option.
    • If you want to use HTTP, you must specify the --http-port option.
    • If you want to use HTTPS, you must specify the --https-port, --https-cert and --https-key options.
    • If you want to use Swagger, you must specify the --swagger-url-path option.
  • Use the -h, --help option to see a full list of options.
  • All options can be set as environment variables. This can be useful when operating in a container like Docker.
    • Normally, command-line options are prioritized over environment variables, but if the ONNX_SERVER_CONFIG_PRIORITY=env environment variable exists, environment variables have higher priority. Within a Docker image, environment variables have higher priority.

Options

Option Environment Description
--workers ONNX_SERVER_WORKERS Worker thread pool size.
Default: 4
--request-payload-limit ONNX_SERVER_REQUEST_PAYLOAD_LIMIT HTTP/HTTPS request payload size limit. Also bounds the JSON body on the TCP backend.
Default: 1024 * 1024 * 10(10MB)`
--model-upload-limit ONNX_SERVER_MODEL_UPLOAD_LIMIT TCP CREATE_SESSION model binary upload size limit. The uploaded model is streamed to disk (not held in RAM) and loaded from there.
Default: 1024 * 1024 * 1024 * 2(2GB)
--model-upload-dir ONNX_SERVER_MODEL_UPLOAD_DIR Directory for streaming uploaded model binaries to disk (TCP CREATE_SESSION).
If empty, the OS temp directory is used. Set a disk-backed path when the temp dir is tmpfs (RAM), so large uploads do not defeat the streaming (OOM-avoidance) purpose.
Default: empty (OS temp directory)
--model-dir ONNX_SERVER_MODEL_DIR Model directory path
The onnx model files must be located in the following path:
${model_dir}/${model_name}/${model_version}/model.onnx or
${model_dir}/${model_name}/${model_version}.onnx
Default: models
--prepare-model ONNX_SERVER_PREPARE_MODEL Pre-create some model sessions at server startup.

Format as a space-separated list of model_name:model_version or model_name:model_version(opt1=val1, opt2=val2, ...). Option keys may use dotted notation to address nested groups (e.g. cuda.device_id, session_options.intra_op_num_threads). Repeating the extensions key accumulates a deduplicated array. Option entries that do not match the grammar are skipped silently rather than failing the whole list.

Examples:

  • model1:v1 model2:v9
  • model1:v1(cuda=true) model2:v9(cuda=1)
  • bert:v1(cuda.device_id=0, cuda.gpu_mem_limit=2147483648)
  • bert:v1(session_options.intra_op_num_threads=4, session_options.graph_optimization_level=all)
  • bert:v1(extensions=/usr/local/lib/libortextensions.so) |

Backend options

Option Environment Description
--tcp-port ONNX_SERVER_TCP_PORT Enable TCP backend and which port number to use.
--http-port ONNX_SERVER_HTTP_PORT Enable HTTP backend and which port number to use.
--https-port ONNX_SERVER_HTTPS_PORT Enable HTTPS backend and which port number to use.
--https-cert ONNX_SERVER_HTTPS_CERT SSL Certification file path for HTTPS
--https-key ONNX_SERVER_HTTPS_KEY SSL Private key file path for HTTPS
--swagger-url-path ONNX_SERVER_SWAGGER_URL_PATH Enable Swagger API document for HTTP/HTTPS backend.
This value cannot start with "/api/" and "/health"
If not specified, swagger document not provided.
eg) /swagger or /api-docs

Log options

Option Environment Description
--log-level ONNX_SERVER_LOG_LEVEL Log level(debug, info, warn, error, fatal)
--log-file ONNX_SERVER_LOG_FILE Log file path.
If not specified, logs will be printed to stdout.
--access-log-file ONNX_SERVER_ACCESS_LOG_FILE Access log file path.
If not specified, logs will b

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++aicontributions-welcomecudadeep-learning

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言