Link to this sectionUltralytics를 위한 Modal 퀵스타트 가이드#
This guide provides a comprehensive introduction to running Ultralytics YOLO26 on Modal, covering serverless GPU inference and model training.
Link to this sectionModal이란 무엇인가요?#
Modal is a serverless cloud computing platform for AI and machine learning workloads. It handles provisioning, scaling, and execution automatically — you write Python code locally and Modal runs it in the cloud with GPU access. This makes it ideal for running deep learning models like YOLO26 without managing infrastructure.
Link to this section학습 내용#
- Modal 설정 및 인증
- Modal에서 YOLO26 추론 실행하기
- 더 빠른 추론을 위한 GPU 사용
- Modal에서 YOLO26 모델 학습하기
Link to this section사전 요구 사항#
- Modal 계정 (modal.com에서 무료로 가입)
- 로컬 머신에 설치된 Python 3.9 이상
Link to this section설치#
Modal Python 패키지 설치:
pip install modal그런 다음 Modal 계정으로 CLI 인증을 수행합니다:
modal token newmodal token new 명령어를 실행하면 Modal 계정 인증을 위한 브라우저 창이 열립니다. 인증 후에는 터미널에서 Modal 명령어를 실행할 수 있습니다.
Link to this sectionYOLO26 추론 실행#
modal_yolo.py라는 새 Python 파일을 생성하여 다음 코드로 추론을 실행합니다:
"""
Modal + Ultralytics YOLO26 Quickstart
Run: modal run modal_yolo.py.
"""
import modal
app = modal.App("ultralytics-yolo")
image = modal.Image.debian_slim(python_version="3.11").apt_install("libgl1", "libglib2.0-0").pip_install("ultralytics")
@app.function(image=image)
def predict(image_url: str):
"""Run YOLO26 inference on an image URL."""
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
results = model(image_url)
for r in results:
print(f"Detected {len(r.boxes)} objects:")
for box in r.boxes:
print(f" - {model.names[int(box.cls)]}: {float(box.conf):.2f}")
@app.local_entrypoint()
def main():
"""Test inference with sample image."""
predict.remote("https://ultralytics.com/images/bus.jpg")추론 실행:
modal run modal_yolo.py예상 출력:
✓ Initialized. View run at https://modal.com/apps/your-username/main/ap-xxxxxxxx
✓ Created objects.
├── 🔨 Created mount modal_yolo.py
└── 🔨 Created function predict.
Downloading https://github.com/ultralytics/assets/releases/download/v8.4.0/yolo26n.pt to 'yolo26n.pt'...
Downloading https://ultralytics.com/images/bus.jpg to 'bus.jpg'...
image 1/1 /root/bus.jpg: 640x480 4 persons, 1 bus, 377.8ms
Speed: 5.8ms preprocess, 377.8ms inference, 0.3ms postprocess per image at shape (1, 3, 640, 480)
Detected 5 objects:
- bus: 0.92
- person: 0.91
- person: 0.91
- person: 0.87
- person: 0.53
✓ App completed.Modal 대시보드에서 함수 실행을 모니터링할 수 있습니다:
Link to this section더 빠른 추론을 위해 GPU 사용하기#
gpu 파라미터를 지정하여 함수에 GPU를 추가합니다:
@app.function(image=image, gpu="T4") # Options: "T4", "A10G", "A100", "H100"
def predict_gpu(image_url: str):
"""Run YOLO26 inference on GPU."""
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
results = model(image_url)
print(results[0].boxes)| GPU | 메모리 | 최적 대상 |
|---|---|---|
| T4 | 16 GB | 추론, 소형 모델 학습 |
| A10G | 24 GB | 중형 학습 작업 |
| A100 | 40 GB | 대규모 학습 |
| H100 | 80 GB | 최대 성능 |
Link to this sectionModal에서 YOLO26 학습하기#
학습을 위해서는 GPU와 지속적인 스토리지를 위한 Modal Volumes를 사용하십시오. train_yolo.py라는 새 Python 파일을 생성합니다:
import modal
app = modal.App("ultralytics-training")
volume = modal.Volume.from_name("yolo-training-vol", create_if_missing=True)
image = modal.Image.debian_slim(python_version="3.11").apt_install("libgl1", "libglib2.0-0").pip_install("ultralytics")
@app.function(image=image, gpu="T4", timeout=3600, volumes={"/data": volume})
def train():
"""Train YOLO26 model on Modal."""
from ultralytics import YOLO
model = YOLO("yolo26n.pt")
model.train(data="coco8.yaml", epochs=3, imgsz=640, project="/data/runs")
@app.local_entrypoint()
def main():
train.remote()학습 실행:
modal run train_yolo.pyModal 볼륨은 함수 실행 간에 데이터를 유지합니다. 학습된 가중치는 /data/runs/train/weights/에 저장됩니다.
축하합니다! Modal에서 Ultralytics YOLO26을 성공적으로 설정했습니다. 추가 학습을 위해 다음을 확인하십시오:
- 고급 기능을 위한 Ultralytics YOLO26 문서 탐색
- 나만의 데이터셋으로 사용자 지정 모델 학습하기 알아보기
- 컨테이너화된 배포를 위해 Docker 퀵스타트 시도
- 고급 플랫폼 기능을 위해 Modal 문서 방문
Link to this sectionFAQ#
Link to this sectionYOLO26 워크로드를 위한 적절한 GPU는 어떻게 선택하나요?#
추론의 경우 일반적으로 NVIDIA T4(16GB)로 충분하며 비용 효율적입니다. 학습이나 YOLO26x와 같은 더 큰 모델의 경우 A10G 또는 A100 GPU를 고려하십시오.
Link to this sectionModal에서 YOLO26을 실행하는 데 드는 비용은 얼마인가요?#
Modal은 초당 과금 방식을 사용합니다. 예상 요금: CPU 시간당 약 $0.05, T4 시간당 약 $0.59, A10G 시간당 약 $1.10, A100 시간당 약 $2.10입니다. 현재 요금은 Modal 요금 안내를 확인하십시오.
Link to this section제가 직접 학습시킨 YOLO 모델을 사용할 수 있나요?#
네, Modal 볼륨에서 가중치 파일을 로드하여 Modal에서 직접 학습시킨 YOLO 모델을 실행할 수 있습니다:
model = YOLO("/data/my_custom_model.pt")사용자 지정 모델 학습에 대한 자세한 내용은 학습 가이드를 참조하십시오.