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 modalmodal 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/detect/train/weights/에 저장됩니다.
축하합니다! Modal에서 Ultralytics YOLO26을 성공적으로 설정하셨습니다. 추가 학습 자료:
- 고급 기능을 알아보려면 Ultralytics YOLO26 문서를 살펴보십시오
- 사용자 지정 데이터셋으로 모델을 학습하는 방법에 대해 알아보십시오
- 고급 플랫폼 기능을 확인하려면 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 볼륨에서 사용자 지정 모델을 불러올 수 있습니다:
model = YOLO("/data/my_custom_model.pt")사용자 지정 모델 학습에 대한 자세한 내용은 학습 가이드를 참조하십시오.