본문 바로가기
C.W.K.
Stream
Lesson 02 of 05 · published

TGI: Pull, Run, Tune

~30 min · serving, tgi

Level 0스카우트
0 XP0/50 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

TGI는 Docker로 빠르게 시작할 수 있어

모델을 정하고 가중치 캐시 볼륨을 연결한 뒤 8080 포트를 열고 --model-id를 넘겨. 첫 실행은 가중치를 받아 오래 걸리지만 같은 볼륨을 재사용하면 다음 시작은 캐시에서 읽어 빨라져.

처리량과 메모리를 함께 조정해

  • --model-id에는 HF 저장소 ID나 로컬 경로를 넣어.
  • --quantize는 모델 변형에 맞춰 AWQ·GPTQ·bitsandbytes·NF4·fp8을 선택해.
  • --max-concurrent-requests는 동시에 처리할 요청 수를 정해.
  • --max-input-length--max-total-tokens를 늘리면 요청 하나의 KV cache가 커져 동시성이 줄 수 있어.
  • --num-shard는 여러 GPU에 tensor parallel로 모델을 나눠.

운영에 필요한 끝점도 함께 와

생성과 스트리밍, OpenAI 호환 chat completions뿐 아니라 /info, /health, Prometheus용 /metrics가 기본 제공돼.

Code

한 명령으로 TGI 실행·bash
# Single-GPU 7B 모델
docker run --gpus all --shm-size 1g -p 8080:80 \
  -v $PWD/data:/data \
  ghcr.io/huggingface/text-generation-inference:latest \
  --model-id meta-llama/Llama-3.1-8B-Instruct \
  --quantize bitsandbytes-nf4 \
  --max-concurrent-requests 64

# 다른 터미널:
curl http://localhost:8080/info | python -m json.tool
OpenAI 호환 엔드포인트로서의 TGI·bash
# TGI 가 /v1/chat/completions 를 out of the box 노출.
curl http://localhost:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "tgi",
    "messages": [{"role":"user","content":"Hello"}],
    "max_tokens": 50
  }'

External links

Exercise

최신 TGI 이미지 pull. 1-3B instruct 모델을 --quantize bitsandbytes-nf4 로 실행. /info, /health, /metrics hit. OpenAI 호환 엔드포인트로 chat completion 보내. 컨테이너 stop, restart, 볼륨에서 가중치 warm-cache 검증.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.