Skip to content

Commit bb50dee

Browse files
committed
[Feat] GPU 지원 Dockerfile 적용 (CUDA 12.4 + cuDNN)
1 parent e717e94 commit bb50dee

3 files changed

Lines changed: 146 additions & 20 deletions

File tree

Dockerfile

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
# ===========================================
2-
# PIILOT AI Server Dockerfile
2+
# PIILOT AI Server Dockerfile (GPU 버전)
33
# ===========================================
4-
# Python 3.11 + 시스템 의존성 (ffmpeg, OpenCV 등)
5-
# AI 모델은 이미지에 포함하지 않고, Docker Volume으로 캐시합니다.
6-
# (처음 시작할 때 자동 다운로드, 이후엔 캐시에서 로드)
4+
# NVIDIA CUDA 12.4 + cuDNN 기반 이미지
5+
# g4dn.xlarge (T4 GPU) 에서 사용합니다.
76
# ===========================================
87

9-
FROM python:3.11-slim
8+
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
9+
10+
# Python 3.11 설치
11+
RUN apt-get update && apt-get install -y \
12+
software-properties-common \
13+
&& add-apt-repository ppa:deadsnakes/ppa \
14+
&& apt-get update && apt-get install -y \
15+
python3.11 \
16+
python3.11-venv \
17+
python3.11-dev \
18+
python3-pip \
19+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \
20+
&& rm -rf /var/lib/apt/lists/*
1021

1122
# 시스템 의존성 설치
12-
# - build-essential, libpq-dev: Python 패키지 빌드에 필요
13-
# - libgl1 (libgl1-mesa-dri): OpenCV용 OpenGL (libgl1-mesa-glx는 Debian trixie에서 삭제됨)
14-
# - libglib2.0-0, libsm6, libxext6, libxrender-dev: OpenCV (이미지 처리)
15-
# - libgomp1: XGBoost (머신러닝)
16-
# - ffmpeg: 오디오/비디오 처리 (Whisper STT, 비디오 마스킹)
17-
# - curl: 헬스체크용
1823
RUN apt-get update && apt-get install -y \
1924
build-essential \
2025
libpq-dev \
@@ -30,27 +35,29 @@ RUN apt-get update && apt-get install -y \
3035

3136
WORKDIR /app
3237

33-
# 의존성 먼저 설치 (캐시 활용)
34-
# requirements.txt가 바뀌지 않으면 pip install을 건너뜁니다
38+
# PyTorch CUDA 버전 먼저 설치 (캐시 활용)
39+
RUN pip3 install --no-cache-dir \
40+
torch torchvision torchaudio \
41+
--index-url https://download.pytorch.org/whl/cu124
42+
43+
# 나머지 의존성 설치
3544
COPY requirements.txt .
36-
RUN pip install --no-cache-dir -r requirements.txt
45+
RUN pip3 install --no-cache-dir -r requirements.txt
3746

3847
# 애플리케이션 코드 복사
3948
COPY . .
4049

41-
# 출력 디렉토리 생성 (마스킹 결과 파일 저장용)
50+
# 출력 디렉토리 생성
4251
RUN mkdir -p /app/output_file/documents \
4352
/app/output_file/images \
4453
/app/output_file/videos \
4554
/app/output_file/audio
4655

47-
# 8000 포트 사용
4856
EXPOSE 8000
4957

50-
# 헬스체크: 30초마다 /health 호출
51-
# start_period: 120초 (AI 모델 로딩 시간이 길어서 2분 대기)
52-
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
58+
# 헬스체크
59+
HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=3 \
5360
CMD curl -f http://localhost:8000/health || exit 1
5461

5562
# FastAPI 서버 실행
56-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
63+
CMD ["python3", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.cpu

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ===========================================
2+
# PIILOT AI Server Dockerfile
3+
# ===========================================
4+
# Python 3.11 + 시스템 의존성 (ffmpeg, OpenCV 등)
5+
# AI 모델은 이미지에 포함하지 않고, Docker Volume으로 캐시합니다.
6+
# (처음 시작할 때 자동 다운로드, 이후엔 캐시에서 로드)
7+
# ===========================================
8+
9+
FROM python:3.11-slim
10+
11+
# 시스템 의존성 설치
12+
# - build-essential, libpq-dev: Python 패키지 빌드에 필요
13+
# - libgl1 (libgl1-mesa-dri): OpenCV용 OpenGL (libgl1-mesa-glx는 Debian trixie에서 삭제됨)
14+
# - libglib2.0-0, libsm6, libxext6, libxrender-dev: OpenCV (이미지 처리)
15+
# - libgomp1: XGBoost (머신러닝)
16+
# - ffmpeg: 오디오/비디오 처리 (Whisper STT, 비디오 마스킹)
17+
# - curl: 헬스체크용
18+
RUN apt-get update && apt-get install -y \
19+
build-essential \
20+
libpq-dev \
21+
libgl1 \
22+
libglib2.0-0 \
23+
libsm6 \
24+
libxext6 \
25+
libxrender-dev \
26+
libgomp1 \
27+
ffmpeg \
28+
curl \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
WORKDIR /app
32+
33+
# 의존성 먼저 설치 (캐시 활용)
34+
# requirements.txt가 바뀌지 않으면 pip install을 건너뜁니다
35+
COPY requirements.txt .
36+
RUN pip install --no-cache-dir -r requirements.txt
37+
38+
# 애플리케이션 코드 복사
39+
COPY . .
40+
41+
# 출력 디렉토리 생성 (마스킹 결과 파일 저장용)
42+
RUN mkdir -p /app/output_file/documents \
43+
/app/output_file/images \
44+
/app/output_file/videos \
45+
/app/output_file/audio
46+
47+
# 8000 포트 사용
48+
EXPOSE 8000
49+
50+
# 헬스체크: 30초마다 /health 호출
51+
# start_period: 120초 (AI 모델 로딩 시간이 길어서 2분 대기)
52+
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
53+
CMD curl -f http://localhost:8000/health || exit 1
54+
55+
# FastAPI 서버 실행
56+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.gpu

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# ===========================================
2+
# PIILOT AI Server Dockerfile (GPU 버전)
3+
# ===========================================
4+
# NVIDIA CUDA 12.4 + cuDNN 기반 이미지
5+
# g4dn.xlarge (T4 GPU) 에서 사용합니다.
6+
# ===========================================
7+
8+
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
9+
10+
# Python 3.11 설치
11+
RUN apt-get update && apt-get install -y \
12+
software-properties-common \
13+
&& add-apt-repository ppa:deadsnakes/ppa \
14+
&& apt-get update && apt-get install -y \
15+
python3.11 \
16+
python3.11-venv \
17+
python3.11-dev \
18+
python3-pip \
19+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 \
20+
&& rm -rf /var/lib/apt/lists/*
21+
22+
# 시스템 의존성 설치
23+
RUN apt-get update && apt-get install -y \
24+
build-essential \
25+
libpq-dev \
26+
libgl1 \
27+
libglib2.0-0 \
28+
libsm6 \
29+
libxext6 \
30+
libxrender-dev \
31+
libgomp1 \
32+
ffmpeg \
33+
curl \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
WORKDIR /app
37+
38+
# PyTorch CUDA 버전 먼저 설치 (캐시 활용)
39+
RUN pip3 install --no-cache-dir \
40+
torch torchvision torchaudio \
41+
--index-url https://download.pytorch.org/whl/cu124
42+
43+
# 나머지 의존성 설치
44+
COPY requirements.txt .
45+
RUN pip3 install --no-cache-dir -r requirements.txt
46+
47+
# 애플리케이션 코드 복사
48+
COPY . .
49+
50+
# 출력 디렉토리 생성
51+
RUN mkdir -p /app/output_file/documents \
52+
/app/output_file/images \
53+
/app/output_file/videos \
54+
/app/output_file/audio
55+
56+
EXPOSE 8000
57+
58+
# 헬스체크
59+
HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=3 \
60+
CMD curl -f http://localhost:8000/health || exit 1
61+
62+
# FastAPI 서버 실행
63+
CMD ["python3", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)