YOLO Vision 2026:

Triton Inference Server と Ultralytics YOLO26#

Triton Inference Server(旧 TensorRT Inference Server)は、NVIDIA が開発したオープンソースのソフトウェアソリューションです。NVIDIA GPU に最適化されたクラウド推論ソリューションを提供します。Triton により、本番環境での AI モデルの大規模なデプロイが簡素化されます。Ultralytics YOLO26 と Triton Inference Server を統合することで、スケーラブルかつ高性能なディープラーニングの推論ワークロードをデプロイできます。このガイドでは、統合の設定とテストの手順を説明します。



Watch: Getting Started with NVIDIA Triton Inference Server.

Triton Inference Server とは?#

Triton Inference Serverは、本番環境で多様なAIモデルをデプロイするように設計されています。PyTorchTensorFlowONNXOpenVINOTensorRTをはじめとする、幅広いディープラーニングおよび機械学習フレームワークをサポートしています。主なユースケースは以下の通りです。

  • 単一のサーバーインスタンスから複数のモデルを提供
  • サーバーを再起動せずにモデルを動的に読み込み、アンロードする機能
  • アンサンブル推論(複数のモデルを組み合わせて結果を得ることが可能)
  • A/B テストやローリングアップデートのためのモデルバージョン管理

Triton Inference Server の主な利点#

Triton Inference Server を Ultralytics YOLO26 と共に使用することには、いくつかの利点があります。

  • 自動バッチ処理: 複数の AI リクエストを処理前にグループ化することで、レイテンシを削減し、推論速度を向上させます。
  • Kubernetes 統合: クラウドネイティブな設計により、Kubernetes とシームレスに連携し、AI アプリケーションの管理とスケーリングを可能にします。
  • ハードウェア固有の最適化: NVIDIA GPU の性能を最大限に引き出します。
  • フレームワークの柔軟性: PyTorchTensorFlowONNXOpenVINOTensorRT を含む複数の AI フレームワークをサポートします。
  • オープンソースでカスタマイズ可能: 特定のニーズに合わせて変更可能であり、さまざまな AI アプリケーションに対して柔軟性を提供します。

前提条件#

先に進む前に、以下の前提条件が満たされていることを確認してください。

  • Docker(>= 28.2.0、CDI GPU アクセス用の NVIDIA Container Toolkit >= 1.18 を含む)または Podman がマシンにインストールされていること
  • ultralytics をインストールします:
    pip install ultralytics
  • tritonclient をインストールします:
    pip install tritonclient[all]

Triton Inference Server のセットアップ#

この完全なセットアップブロックを実行して、Ultralytics YOLO26ONNX にエクスポートし、Triton モデルリポジトリを構築し、Triton Inference Server を起動します:

注意

スクリプト内の runtime スイッチを使用して、コンテナエンジンを選択します:

  • Docker の場合は runtime = "docker" を設定します
  • Podman の場合は runtime = "podman" を設定します
import contextlib
import subprocess
import time
from pathlib import Path

from tritonclient.http import InferenceServerClient

from ultralytics import YOLO

runtime = "docker"  # set to "podman" to use Podman

# 1) Exporting YOLO26 to ONNX Format

# Load a model
model = YOLO("yolo26n.pt")  # load an official model

# Retrieve metadata during export. Metadata needs to be added to config.pbtxt. See next section.
metadata = []

def export_cb(exporter):
    metadata.append(exporter.metadata)

model.add_callback("on_export_end", export_cb)

# Export the model
onnx_file = model.export(format="onnx", dynamic=True)

# 2) Setting Up Triton Model Repository

# Define paths
model_name = "yolo"
triton_repo_path = Path("tmp") / "triton_repo"
triton_model_path = triton_repo_path / model_name

# Create directories
(triton_model_path / "1").mkdir(parents=True, exist_ok=True)

# Move ONNX model to Triton Model path
Path(onnx_file).rename(triton_model_path / "1" / "model.onnx")

# Create config file
(triton_model_path / "config.pbtxt").touch()

data = """
# Add metadata
parameters {
  key: "metadata"
  value {
    string_value: "%s"
  }
}

# Enable TensorRT acceleration (requires a GPU and TensorRT-enabled Triton; remove this block for CPU-only serving)
# The first run will be slow due to TensorRT engine conversion
optimization {
  execution_accelerators {
    gpu_execution_accelerator {
      name: "tensorrt"
      parameters {
        key: "precision_mode"
        value: "FP16"
      }
      parameters {
        key: "max_workspace_size_bytes"
        value: "3221225472"
      }
      parameters {
        key: "trt_engine_cache_enable"
        value: "1"
      }
      parameters {
        key: "trt_engine_cache_path"
        value: "/models/yolo/1"
      }
    }
  }
}
""" % metadata[0]  # noqa

with open(triton_model_path / "config.pbtxt", "w") as f:
    f.write(data)

# 3) Running Triton Inference Server

# Define image https://catalog.ngc.nvidia.com/orgs/nvidia/containers/tritonserver
tag = "nvcr.io/nvidia/tritonserver:26.02-py3"  # 16.17 GB (Compressed Size)

subprocess.call(f"{runtime} pull {tag}", shell=True)

# CDI GPU request works identically on Docker and Podman
gpu_flags = "--device nvidia.com/gpu=all"

container_name = "triton_server"

# Note: The :z flag on the volume mount is necessary for systems with SELinux (like Fedora/RHEL)
subprocess.call(
    f"{runtime} run -d --rm --name {container_name} {gpu_flags} -v {triton_repo_path.absolute()}:/models:z -p 8000:8000 {tag} tritonserver --model-repository=/models",
    shell=True,
)

# Wait for the Triton server to start
triton_client = InferenceServerClient(url="127.0.0.1:8000", verbose=False, ssl=False)

# Wait until model is ready
for _ in range(10):
    with contextlib.suppress(Exception):
        assert triton_client.is_model_ready(model_name)
        break
    time.sleep(1)

推論の実行#

Triton Server モデルを使用して推論を実行する:

from ultralytics import YOLO

# Load the Triton Server model
model = YOLO("http://127.0.0.1:8000/yolo", task="detect")

# Run inference on the server
results = model("path/to/image.jpg")

コンテナをクリーンアップします:

import subprocess

runtime = "docker"  # set to "podman" to use Podman
container_name = "triton_server"  # Kill the named container
subprocess.call(f"{runtime} kill {container_name}", shell=True)

TensorRT 最適化(オプション)#

さらに高いパフォーマンスを実現するために、Triton Inference Server で TensorRT を使用することができます。TensorRT は NVIDIA GPU 専用に構築された高性能なディープラーニングオプタイマイザであり、推論速度を大幅に向上させることができます。

Triton で TensorRT を使用する主な利点は以下のとおりです:

  • 最適化されていないモデルと比較して、推論速度が最大 36 倍高速化
  • GPU 稼働率を最大化するためのハードウェア固有の最適化
  • 精度を維持したまま、低精度フォーマット(INT8、FP16)をサポート
  • 演算オーバーヘッドを削減するレイヤー融合

TensorRT を直接使用するには、Ultralytics YOLO26 モデルを TensorRT 形式にエクスポートします:

from ultralytics import YOLO

# Load the YOLO26 model
model = YOLO("yolo26n.pt")

# Export the model to TensorRT format
model.export(format="engine")  # creates 'yolo26n.engine'

TensorRT の最適化の詳細については、TensorRT 統合ガイドを参照してください。

これで、Triton Inference Server 上で Ultralytics YOLO26 モデルをデプロイして実行し、スケーラブルで高性能な推論を行うことができます。詳細については、公式の Triton ドキュメントを参照するか、Ultralytics コミュニティに質問してください。

よくある質問 (FAQ)#

Ultralytics YOLO26 を NVIDIA Triton Inference Server にセットアップする方法は?#

Ultralytics YOLO26NVIDIA Triton Inference Server の設定には、いくつかの重要な手順が含まれます:

  1. YOLO26 を ONNX 形式にエクスポートする

    from ultralytics import YOLO
    
    # Load a model
    model = YOLO("yolo26n.pt")  # load an official model
    
    # Export the model to ONNX format
    onnx_file = model.export(format="onnx", dynamic=True)
  2. Triton モデルリポジトリをセットアップする

    from pathlib import Path
    
    # Define paths
    model_name = "yolo"
    triton_repo_path = Path("tmp") / "triton_repo"
    triton_model_path = triton_repo_path / model_name
    
    # Create directories
    (triton_model_path / "1").mkdir(parents=True, exist_ok=True)
    Path(onnx_file).rename(triton_model_path / "1" / "model.onnx")
    (triton_model_path / "config.pbtxt").touch()
  3. Triton Server を実行する

    import contextlib
    import subprocess
    import time
    
    from tritonclient.http import InferenceServerClient
    
    # Define image https://catalog.ngc.nvidia.com/orgs/nvidia/containers/tritonserver
    tag = "nvcr.io/nvidia/tritonserver:26.02-py3"
    
    runtime = "docker"  # set to "podman" to use Podman
    subprocess.call(f"{runtime} pull {tag}", shell=True)
    
    # CDI GPU request works identically on Docker and Podman
    gpu_flags = "--device nvidia.com/gpu=all"
    
    container_name = "triton_server"
    subprocess.call(
        f"{runtime} run -d --rm --name {container_name} {gpu_flags} -v {triton_repo_path.absolute()}:/models:z -p 8000:8000 {tag} tritonserver --model-repository=/models",
        shell=True,
    )
    
    triton_client = InferenceServerClient(url="127.0.0.1:8000", verbose=False, ssl=False)
    
    for _ in range(10):
        with contextlib.suppress(Exception):
            assert triton_client.is_model_ready(model_name)
            break
        time.sleep(1)

このセットアップにより、高性能な AI モデルの推論のために、Triton Inference Server 上で Ultralytics YOLO26 モデルを大規模に効率よくデプロイすることができます。

Ultralytics YOLO26 を NVIDIA Triton Inference Server と併用することの利点は何ですか?#

Ultralytics YOLO26NVIDIA Triton Inference Server を統合することで、いくつかの利点が得られます:

  • スケーラブルな AI 推論: Triton は単一のサーバーインスタンスから複数のモデルを提供でき、モデルの動的な読み込みとアンロードをサポートしているため、多様な AI ワークロードに対して非常にスケーラブルです。
  • 高性能: NVIDIA GPU に最適化された Triton Inference Server は、高速な推論処理を実現し、オブジェクト検出などのリアルタイムアプリケーションに最適です。
  • アンサンブルとモデルバージョン管理: Triton のアンサンブルモードでは複数のモデルを組み合わせて結果を向上させることができ、モデルバージョン管理機能は A/B テストやローリングアップデートをサポートします。
  • 自動バッチ処理: Triton は複数の推論リクエストを自動的にグループ化し、スループットを大幅に向上させるとともにレイテンシを削減します。
  • デプロイの簡素化: システム全体を刷新することなく AI ワークフローを段階的に最適化できるため、効率的なスケーリングが容易になります。

Ultralytics YOLO26 を Triton で設定して実行する詳細な手順については、Triton Inference Server の設定および推論の実行を参照してください。

Triton Inference Server を使用する前に、YOLO26 モデルを ONNX 形式にエクスポートする必要があるのはなぜですか?#

NVIDIA Triton Inference Serverにデプロイする前にUltralytics YOLO26モデルにONNX(Open Neural Network Exchange)形式を使用すると、いくつかの重要なメリットがあります。

  • 相互運用性: ONNX 形式は異なる deep learning フレームワーク(PyTorch や TensorFlow など)間での転送をサポートしており、より広範な互換性を確保します。
  • 最適化: Triton を含む多くのデプロイ環境は ONNX に最適化されており、推論の高速化とパフォーマンスの向上が可能です。
  • デプロイの容易さ: ONNX はフレームワークやプラットフォーム間で広くサポートされており、さまざまなオペレーティングシステムやハードウェア構成でのデプロイプロセスを簡素化します。
  • フレームワークからの独立: ONNX に変換すると、モデルは元のフレームワークに縛られなくなるため、ポータビリティが向上します。
  • 標準化: ONNX は標準化された表現を提供し、異なる AI フレームワーク間の互換性の問題を克服するのに役立ちます。

モデルをエクスポートするには、以下を使用します:

from ultralytics import YOLO

model = YOLO("yolo26n.pt")
onnx_file = model.export(format="onnx", dynamic=True)

ONNX 統合ガイドの手順に従ってプロセスを完了できます。

Triton Inference Server 上で Ultralytics YOLO26 モデルを使用して推論を実行できますか?#

はい、NVIDIA Triton Inference Server上でUltralytics YOLO26モデルを使用して推論を実行できます。モデルをTriton Model Repositoryに設定し、サーバーを起動したら、次のようにモデルを読み込んで推論を実行できます。

from ultralytics import YOLO

# Load the Triton Server model
model = YOLO("http://127.0.0.1:8000/yolo", task="detect")

# Run inference on the server
results = model("path/to/image.jpg")

このアプローチにより、使い慣れた Ultralytics YOLO インターフェースを使用しながら、Triton の最適化を活用できます。

Ultralytics YOLO26 は、デプロイメントにおいて TensorFlow や PyTorch モデルと比べてどうですか?#

Ultralytics YOLO26 は、デプロイにおいて TensorFlow および PyTorch モデルと比較して、いくつかの独自の利点を提供します。

  • リアルタイムパフォーマンス: リアルタイムのオブジェクト検出タスクに最適化された Ultralytics YOLO26 は、最先端の精度と速度を提供し、ライブ映像分析を必要とするアプリケーションに最適です。
  • 使いやすさ: Ultralytics YOLO26 は Triton Inference Server とシームレスに統合され、さまざまなエクスポート形式(ONNXTensorRT)をサポートしているため、さまざまなデプロイシナリオに対応できます。
  • 高度な機能: Ultralytics YOLO26 には、動的モデル読み込み、モデルバージョニング、アンサンブル推論などの機能が含まれており、これらはスケーラブルで信頼性の高い AI デプロイに不可欠です。
  • 簡素化された API: Ultralytics API は、さまざまなデプロイターゲット間で一貫したインターフェースを提供し、学習コストと開発時間を削減します。
  • エッジ最適化: Ultralytics YOLO26 モデルはエッジデプロイを念頭に置いて設計されており、リソースが制限されたデバイスでも優れたパフォーマンスを発揮します。

詳細については、モデルエクスポートガイドのデプロイオプションを比較してください。

コメント