C.W.K.
Stream
Lesson 02 of 05 · published

Docker 배포

~11 min · docker, deployment, config

Level 0Level 0
0 XP0/78 lessons0/17 achievements
0/100 XP to next level100 XP to go0% complete

두 명령으로 serving endpoint 시작

TF Serving 시작 가장 빠른 경로는 공식 Docker 이미지. SavedModel directory 마운트, model 이름 설정하면 REST (8501)랑 gRPC (8500) 둘 다 노출하는 production endpoint 완성.

필수 directory 구조: {model_name}/{version_number}/saved_model.pb. TF Serving이 가장 큰 정수 서브디렉토리 스캔으로 새 버전 자동 감지하고 재시작 없이 hot-swap.

여러 model 운영하려면 models.config 파일 작성해서 각 model + base path 나열. 서버 하나, model 수십 개, config 업데이트 하나.

Code

단일 model serving·bash
# Pull TF Serving image
docker pull tensorflow/serving             # CPU
docker pull tensorflow/serving:latest-gpu   # GPU

# Serve a model on REST port 8501
docker run -p 8501:8501 \
  --mount type=bind,source=/path/to/my_model/,target=/models/my_model \
  -e MODEL_NAME=my_model \
  -t tensorflow/serving

# Expose both gRPC (8500) and REST (8501)
docker run -p 8500:8500 -p 8501:8501 \
  --mount type=bind,source=/path/to/my_model/,target=/models/my_model \
  -e MODEL_NAME=my_model \
  -t tensorflow/serving

# GPU serving
docker run --gpus all -p 8501:8501 \
  --mount type=bind,source=/path/to/gpu_model/,target=/models/gpu_model \
  -e MODEL_NAME=gpu_model \
  -t tensorflow/serving:latest-gpu
Config 파일로 multi-model·bash
# models.config
cat <<EOF > models.config
model_config_list {
  config {
    name: 'image_classifier'
    base_path: '/models/image_classifier/'
    model_platform: 'tensorflow'
  }
  config {
    name: 'text_classifier'
    base_path: '/models/text_classifier/'
    model_platform: 'tensorflow'
    model_version_policy { latest { num_versions: 2 } }
  }
}
EOF

# Serve with config
docker run -p 8500:8500 -p 8501:8501 \
  --mount type=bind,source=$(pwd)/models/,target=/models/ \
  --mount type=bind,source=$(pwd)/models.config,target=/models/models.config \
  -t tensorflow/serving \
  --model_config_file=/models/models.config
필수 directory 구조·bash
my_model/
├── 1/                        # version 1 (first deploy)
│   ├── saved_model.pb
│   └── variables/
│       ├── variables.index
│       └── variables.data-00000-of-00001
└── 2/                        # version 2 (updated)
    ├── saved_model.pb
    └── variables/
# TF Serving auto-serves version 2 when detected

Progress

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

댓글 0

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

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