ONNX 运行时服务器: ONNX 运行时服务器是一个服务器,提供用于 ONNX 推理的 TCP 和 HTTP/HTTPS REST API。
ONNX 运行时服务器: ONNX 运行时服务器是一个服务器,提供用于 ONNX 推理的 TCP 和 HTTP/HTTPS REST API。
download-onnxruntime-linux.sh script/usr/local/onnxruntime./usr/local/onnxruntime/lib to /etc/ld.so.conf.d/onnxruntime.conf and run ldconfig.brew install onnxruntimesudo apt install cmake pkg-config libboost-all-dev libssl-dev
# optional, for running tests
sudo apt install libgtest-dev# 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-toolkitbrew install cmake boost opensslcmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
sudo cmake --install build --prefix /usr/local/onnxruntime-server| OS | Method | Command |
|---|---|---|
| Arch Linux | AUR | yay -S onnxruntime-server |
--model-dir) where the models are located.${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 |
--tcp-port option.--http-port option.--https-port, --https-cert and --https-key options.--swagger-url-path option.-h, --help option to see a full list of options.ONNX_SERVER_CONFIG_PRIORITY=env environment variable exists, environment variables have higher priority.
Within a Docker image, environment variables have higher priority.| 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:v9model1: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) || 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 |
| 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,或尚未同步最近议题。