Triton ์ถ๋ก ์๋ฒ Ultralytics YOLOv8
Triton ์ถ๋ก ์๋ฒ (์ด์ ๋ช ์นญ: TensorRT ์ถ๋ก ์๋ฒ)๋ NVIDIA์์ ๊ฐ๋ฐํ ์คํ ์์ค ์ํํธ์จ์ด ์๋ฃจ์ ์ ๋๋ค. Triton ์ ํ๋ก๋์ ํ๊ฒฝ์์ ๋๊ท๋ชจ๋ก AI ๋ชจ๋ธ์ ๋ฐฐํฌํ๋ ์์ ์ ๊ฐ์ํํฉ๋๋ค. Ultralytics YOLOv8 ๊ณผ Triton ์ถ๋ก ์๋ฒ๋ฅผ ํตํฉํ๋ฉด ํ์ฅ ๊ฐ๋ฅํ ๊ณ ์ฑ๋ฅ ๋ฅ ๋ฌ๋ ์ถ๋ก ์ํฌ๋ก๋๋ฅผ ๋ฐฐํฌํ ์ ์์ต๋๋ค. ์ด ๊ฐ์ด๋๋ ํตํฉ์ ์ค์ ํ๊ณ ํ ์คํธํ๋ ๋จ๊ณ๋ฅผ ์ ๊ณตํฉ๋๋ค.
Watch: NVIDIA ์์ํ๊ธฐ Triton ์ถ๋ก ์๋ฒ.
Triton ์ถ๋ก ์๋ฒ๋ ๋ฌด์์ธ๊ฐ์?
Triton ์ถ๋ก ์๋ฒ๋ ํ๋ก๋์ ํ๊ฒฝ์์ ๋ค์ํ AI ๋ชจ๋ธ์ ๋ฐฐํฌํ๋๋ก ์ค๊ณ๋์์ต๋๋ค. TensorFlow , PyTorch, ONNX ๋ฐํ์ ๋ฑ์ ํฌํจํ ๋ค์ํ ๋ฅ ๋ฌ๋ ๋ฐ ๋จธ์ ๋ฌ๋ ํ๋ ์์ํฌ๋ฅผ ์ง์ํฉ๋๋ค. ์ฃผ์ ์ฌ์ฉ ์ฌ๋ก๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- ๋จ์ผ ์๋ฒ ์ธ์คํด์ค์์ ์ฌ๋ฌ ๋ชจ๋ธ์ ์๋น์คํฉ๋๋ค.
- ์๋ฒ ์ฌ์์ ์์ด ๋์ ๋ชจ๋ธ ๋ก๋ฉ ๋ฐ ์ธ๋ก๋ฉ.
- ์์๋ธ ์ถ๋ก ์ ํตํด ์ฌ๋ฌ ๋ชจ๋ธ์ ํจ๊ป ์ฌ์ฉํ์ฌ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
- A/B ํ ์คํธ ๋ฐ ๋กค๋ง ์ ๋ฐ์ดํธ๋ฅผ ์ํ ๋ชจ๋ธ ๋ฒ์ ๊ด๋ฆฌ.
์ ์ ์กฐ๊ฑด
๊ณ์ ์งํํ๊ธฐ ์ ์ ๋ค์ ์ฌ์ ์๊ตฌ ์ฌํญ์ด ์ถฉ์กฑ๋๋์ง ํ์ธํ์ธ์:
- ๋จธ์ ์ Docker๊ฐ ์ค์น๋์ด ์์ต๋๋ค.
- ์ค์น
tritonclient
:
YOLOv8 ์์ ONNX ํ์์ผ๋ก ๋ด๋ณด๋ด๊ธฐ
๋ชจ๋ธ์ Triton ์ ๋ฐฐํฌํ๊ธฐ ์ ์ ONNX ํ์์ผ๋ก ๋ด๋ณด๋ด์ผ ํฉ๋๋ค. ONNX ํ์์ ์๋ก ๋ค๋ฅธ ๋ฅ ๋ฌ๋ ํ๋ ์์ํฌ ๊ฐ์ ๋ชจ๋ธ์ ์ ์กํ ์ ์๋ ํ์(Open Neural Network Exchange)์
๋๋ค. ๋ชจ๋ธ์ ๋ฐฐํฌํ๊ธฐ ์ ์ export
ํจ์์์ YOLO
ํด๋์ค:
from ultralytics import YOLO
# Load a model
model = YOLO('yolov8n.pt') # load an official model
# Export the model
onnx_file = model.export(format='onnx', dynamic=True)
Triton ๋ชจ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ ์ค์
Triton ๋ชจ๋ธ ์ ์ฅ์๋ Triton ์์ ๋ชจ๋ธ์ ์ก์ธ์คํ๊ณ ๋ก๋ํ ์ ์๋ ์ ์ฅ ์์น์ ๋๋ค.
-
ํ์ํ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ๋ง๋ญ๋๋ค:
-
๋ด๋ณด๋ธ ONNX ๋ชจ๋ธ์ Triton ๋ฆฌํฌ์งํ ๋ฆฌ๋ก ์ด๋ํฉ๋๋ค:
Triton ์ถ๋ก ์๋ฒ ์คํ
Docker๋ฅผ ์ฌ์ฉํ์ฌ Triton ์ถ๋ก ์๋ฒ๋ฅผ ์คํํฉ๋๋ค:
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:23.09-py3' # 6.4 GB
# Pull the image
subprocess.call(f'docker pull {tag}', shell=True)
# Run the Triton server and capture the container ID
container_id = subprocess.check_output(
f'docker run -d --rm -v {triton_repo_path}:/models -p 8000:8000 {tag} tritonserver --model-repository=/models',
shell=True).decode('utf-8').strip()
# Wait for the Triton server to start
triton_client = InferenceServerClient(url='localhost: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 ์๋ฒ ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ์ถ๋ก ์ ์คํํฉ๋๋ค:
from ultralytics import YOLO
# Load the Triton Server model
model = YOLO(f'http://localhost:8000/yolo', task='detect')
# Run inference on the server
results = model('path/to/image.jpg')
์ปจํ ์ด๋๋ฅผ ์ ๋ฆฌํฉ๋๋ค:
# Kill and remove the container at the end of the test
subprocess.call(f'docker kill {container_id}', shell=True)
์์ ๋จ๊ณ์ ๋ฐ๋ผ Triton ์ถ๋ก ์๋ฒ์์ Ultralytics YOLOv8 ๋ชจ๋ธ์ ํจ์จ์ ์ผ๋ก ๋ฐฐํฌํ๊ณ ์คํํ์ฌ ๋ฅ ๋ฌ๋ ์ถ๋ก ์์ ์ ์ํ ํ์ฅ ๊ฐ๋ฅํ ๊ณ ์ฑ๋ฅ ์๋ฃจ์ ์ ์ ๊ณตํ ์ ์์ต๋๋ค. ๋ฌธ์ ๊ฐ ๋ฐ์ํ๊ฑฐ๋ ์ถ๊ฐ ์ง๋ฌธ์ด ์๋ ๊ฒฝ์ฐ ๊ณต์ Triton ์ค๋ช ์๋ฅผ ์ฐธ์กฐํ๊ฑฐ๋ Ultralytics ์ปค๋ฎค๋ํฐ์ ๋ฌธ์ํ์ฌ ์ง์์ ๋ฐ์ผ์ธ์.