README 문서에 RTX 3060 12GB 최적화 설정 추가 및 GPU 요구사항 업데이트, 상태 JSON 파일의 요청 통계 개선, 서버 및 모니터링 포트 변경, x86 전용 설정 수정, 로그 파일에 상태 저장 완료 메시지 추가.

This commit is contained in:
AGX 2025-08-29 00:01:59 +09:00
parent e24dc4873d
commit 460d52bcbf
10 changed files with 835 additions and 881 deletions

View File

@ -74,12 +74,19 @@ FastAPI와 딥러닝을 활용한 병렬 처리 인페인팅 서버입니다. Si
### x86_64 시스템
- **OS**: Ubuntu 18.04 이상
- **Python**: 3.8 이상
- **GPU**: NVIDIA GPU (GTX 1060 이상 권장)
- **Python**: 3.8 이상 (3.10 권장)
- **GPU**: NVIDIA GPU (RTX 3060 12GB 이상 권장)
- **CUDA**: 11.8 이상
- **RAM**: 8GB 이상 권장
- **저장공간**: 10GB 이상
#### RTX 3060 12GB 최적화 설정
- **워커 수**: 4-12개 (자동 조정)
- **세션 풀**: Simple LAMA 4개, MIGAN 4개, REMBG 2개
- **VRAM 관리**: 85% 사용률까지 허용, 25% 이하 시 확장
- **이미지 크기**: 최대 8K (8192x8192) 지원
- **파일 크기**: 최대 100MB 지원
### GPU 요구사항
- **Jetson Xavier**: 내장 Volta GPU (8GB VRAM)
- **x86**: NVIDIA GPU (4GB 이상 VRAM)
@ -99,6 +106,18 @@ chmod +x scripts/*.sh
### 2. 원클릭 설치 및 실행
#### Jetson Xavier (ARM64)
```bash
# Jetson 전용 설치 및 실행
bash scripts/setup_and_run.sh
```
#### x86_64 시스템 (RTX 3060 12GB 등)
```bash
# x86 전용 설치 및 실행
bash scripts/setup_x86.sh
```
```bash
# 시스템 자동 감지 (권장)
./scripts/setup_and_run.sh

View File

@ -28,19 +28,19 @@ class Settings(BaseSettings):
JETSON_TEMP_THRESHOLD: int = 75 # Celsius
# Session pool settings
SIMPLE_LAMA_SESSIONS: int = 2 if IS_JETSON else 2
MIGAN_SESSIONS: int = 2 if IS_JETSON else 2
REMBG_SESSIONS: int = 1 if IS_JETSON else 1
SIMPLE_LAMA_SESSIONS: int = 2 if IS_JETSON else 4
MIGAN_SESSIONS: int = 2 if IS_JETSON else 4
REMBG_SESSIONS: int = 1 if IS_JETSON else 2
# Worker settings (Jetson은 더 적은 워커 사용)
MAX_WORKERS: int = 4 if IS_JETSON else 8
MIN_WORKERS: int = 1 if IS_JETSON else 2
MAX_WORKERS: int = 4 if IS_JETSON else 12
MIN_WORKERS: int = 1 if IS_JETSON else 4
WORKER_TIMEOUT: int = 300 # 5 minutes
# VRAM management (Jetson은 더 보수적인 설정)
VRAM_THRESHOLD_HIGH: float = 0.7 if IS_JETSON else 0.8 # 70% for Jetson
VRAM_THRESHOLD_LOW: float = 0.3 if IS_JETSON else 0.4 # 30% for Jetson
VRAM_CHECK_INTERVAL: int = 20 if IS_JETSON else 30 # More frequent for Jetson
VRAM_THRESHOLD_HIGH: float = 0.7 if IS_JETSON else 0.85 # 70% for Jetson, 85% for x86
VRAM_THRESHOLD_LOW: float = 0.3 if IS_JETSON else 0.25 # 30% for Jetson, 25% for x86
VRAM_CHECK_INTERVAL: int = 20 if IS_JETSON else 20 # More frequent for both
# Model paths
SIMPLE_LAMA_MODEL_PATH: str = "models/simple-lama"
@ -48,8 +48,8 @@ class Settings(BaseSettings):
REMBG_MODEL_PATH: str = "models/rembg"
# Upload settings
MAX_FILE_SIZE: int = 25 * 1024 * 1024 if IS_JETSON else 50 * 1024 * 1024 # 25MB for Jetson
MAX_IMAGE_SIZE: int = 2048 if IS_JETSON else 4096 # Maximum image dimension for Jetson
MAX_FILE_SIZE: int = 25 * 1024 * 1024 if IS_JETSON else 100 * 1024 * 1024 # 25MB for Jetson, 100MB for x86
MAX_IMAGE_SIZE: int = 2048 if IS_JETSON else 8192 # Maximum image dimension for Jetson, 8K for x86
ALLOWED_EXTENSIONS: set = {".jpg", ".jpeg", ".png", ".bmp", ".tiff"}
# Monitoring

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
1308184
1312285

View File

@ -1,9 +1,10 @@
INFO: Started server process [1308201]
INFO: Started server process [1312316]
INFO: Waiting for application startup.
Fan control not available
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO: 127.0.0.1:55776 - "GET /api/simple HTTP/1.1" 200 OK
INFO: 127.0.0.1:35426 - "GET / HTTP/1.1" 200 OK
INFO: ('127.0.0.1', 35442) - "WebSocket /ws" [accepted]
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO: 127.0.0.1:35348 - "GET /api/simple HTTP/1.1" 200 OK
INFO: 127.0.0.1:37590 - "GET / HTTP/1.1" 200 OK
INFO: 127.0.0.1:37590 - "GET /favicon.ico HTTP/1.1" 404 Not Found
INFO: ('127.0.0.1', 37632) - "WebSocket /ws" [accepted]
INFO: connection open

View File

@ -1 +1 @@
1308201
1312316

34
requirements_x86.txt Normal file
View File

@ -0,0 +1,34 @@
fastapi==0.104.1
uvicorn[standard]==0.24.0
python-multipart==0.0.6
pillow==10.0.1
numpy==1.24.3
opencv-python==4.8.1.78
pydantic-settings==2.8.1
psutil==5.9.6
requests==2.31.0
# PyTorch - x86 시스템용 (CUDA 11.8 지원)
# Python 3.10 호환 버전
torch==2.0.1+cu118
torchvision==0.15.2+cu118
# CUDA 관련 (x86 전용)
pycuda==2022.2.2
# 인페인팅 모델들
rembg==2.0.50
simple-lama-inpainting==0.1.0
# 시스템 모니터링
asyncio-throttle==1.0.2
aiofiles==23.2.1
pydantic==2.5.0
# x86 GPU 모니터링
pynvml==11.5.0
nvidia-ml-py3==7.352.0
# 추가 최적화 패키지들
onnxruntime-gpu==1.16.3
tensorflow-gpu==2.13.0

145
scripts/setup_x86.sh Executable file
View File

@ -0,0 +1,145 @@
#!/bin/bash
# x86 시스템용 인페인팅 서버 자동 설치 스크립트
# RTX 3060 12GB 등 x86 GPU를 지원합니다.
# Usage: ./setup_x86.sh
set -e
# 색상 코드
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# 로그 함수들
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# 기본 설정
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENV_PATH="$PROJECT_ROOT/venv"
REQUIREMENTS_FILE="$PROJECT_ROOT/requirements_x86.txt"
log_info "🚀 x86 시스템용 인페인팅 서버 자동 설치 시작"
echo "=========================================="
# 시스템 감지
if [ "$(uname -m)" = "x86_64" ]; then
log_info "🖥️ x86_64 시스템 자동 감지"
else
log_error "❌ x86_64 시스템이 아닙니다. 이 스크립트는 x86 시스템에서만 실행해야 합니다."
exit 1
fi
# Python 환경 확인
log_info "Python 환경 확인 중..."
if ! command -v python3 &> /dev/null; then
log_error "❌ Python3가 설치되지 않았습니다."
exit 1
fi
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
log_info "Python 버전: $PYTHON_VERSION"
# Python 3.10 이상 확인
if ! python3 -c "import sys; exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then
log_error "❌ Python 3.10 이상이 필요합니다. 현재 버전: $PYTHON_VERSION"
exit 1
fi
log_success "Python 환경 확인 완료"
# 가상환경 설정
log_info "가상환경 설정 중..."
if [ ! -d "$VENV_PATH" ]; then
log_info "새로운 가상환경을 생성합니다..."
python3 -m venv "$VENV_PATH"
fi
# 가상환경 활성화
source "$VENV_PATH/bin/activate"
# pip 업그레이드
log_info "pip 업그레이드 중..."
pip install --upgrade pip
log_success "가상환경 설정 완료"
# 의존성 설치
log_info "의존성 설치 중..."
if [ ! -f "$REQUIREMENTS_FILE" ]; then
log_error "❌ requirements_x86.txt 파일을 찾을 수 없습니다."
exit 1
fi
# PyTorch 먼저 설치 (CUDA 11.8)
log_info "PyTorch 설치 중 (CUDA 11.8)..."
pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --index-url https://download.pytorch.org/whl/cu118
# 나머지 의존성 설치
log_info "기타 의존성 설치 중..."
pip install -r "$REQUIREMENTS_FILE"
log_success "의존성 설치 완료"
# 모델 다운로드
log_info "AI 모델 다운로드 중..."
cd "$PROJECT_ROOT"
# 모델 디렉토리 생성
mkdir -p models/simple-lama models/migan models/rembg
# Simple LAMA 모델 다운로드
if [ ! -f "models/simple-lama/big-lama.pt" ]; then
log_info "Simple LAMA 모델 다운로드 중..."
wget -O models/simple-lama/big-lama.pt https://github.com/Saafke/Simple-LAMA/releases/download/v1.0/big-lama.pt
fi
# MIGAN 모델 다운로드
if [ ! -f "models/migan/migan.pt" ]; then
log_info "MIGAN 모델 다운로드 중..."
wget -O models/migan/migan.pt https://github.com/open-mmlab/mmediting/releases/download/v1.0.0/migan_256x256_celeba-hq_20220629-3b7c8c9f.pth
fi
log_success "모델 다운로드 완료"
# 권한 설정
log_info "권한 설정 중..."
chmod +x scripts/*.sh
log_success "권한 설정 완료"
# 설치 완료
echo "=========================================="
log_success "🎉 x86 시스템용 인페인팅 서버 설치가 완료되었습니다!"
echo ""
log_info "다음 명령어로 서버를 시작할 수 있습니다:"
echo " cd $PROJECT_ROOT"
echo " bash scripts/start_server.sh"
echo ""
log_info "또는 자동 설정 및 실행:"
echo " bash scripts/setup_and_run.sh"
echo ""
log_info "서버 포트:"
echo " 메인 서버: http://localhost:8008"
echo " 모니터링: http://localhost:8080"
echo ""
log_info "GPU 설정:"
echo " RTX 3060 12GB 권장 설정이 자동으로 적용됩니다"
echo " 워커 수: 4-8개 (자동 조정)"
echo " 세션 수: Simple LAMA 4개, MIGAN 4개, REMBG 2개"

View File

@ -56,14 +56,14 @@ detect_system() {
SYSTEM_TYPE="x86"
log_info "💻 x86_64 모드로 시작합니다"
# x86 전용 설정
WORKERS=1
MAX_WORKERS=8
MIN_WORKERS=2
VRAM_THRESHOLD_HIGH=0.8
VRAM_THRESHOLD_LOW=0.4
VRAM_CHECK_INTERVAL=30
MAX_FILE_SIZE=50
# x86 전용 설정 (RTX 3060 12GB 최적화)
WORKERS=4
MAX_WORKERS=12
MIN_WORKERS=4
VRAM_THRESHOLD_HIGH=0.85
VRAM_THRESHOLD_LOW=0.25
VRAM_CHECK_INTERVAL=20
MAX_FILE_SIZE=100
else
log_error "지원되지 않는 시스템 아키텍처: $(uname -m)"

View File

@ -6,7 +6,7 @@
"workers_by_status": {
"idle": [
{
"id": "worker_b2710341",
"id": "worker_8aca7695",
"status": "idle",
"task_count": 0,
"error_count": 0,
@ -37,46 +37,62 @@
}
},
"api_stats": {
"total_requests": 3,
"successful_requests": 3,
"failed_requests": 0,
"success_rate": 100.0,
"total_requests": 7,
"successful_requests": 6,
"failed_requests": 1,
"success_rate": 85.71428571428571,
"endpoint_usage": {
"GET /health": 1,
"GET /docs": 1,
"GET /openapi.json": 1
"GET /": 1,
"GET /favicon.ico": 1,
"GET /docs": 2,
"GET /openapi.json": 2
},
"endpoint_stats": {
"GET /health": {
"count": 1,
"avg_time": 0.0018129348754882812,
"min_time": 0.0018129348754882812,
"max_time": 0.0018129348754882812,
"avg_time": 0.0018818378448486328,
"min_time": 0.0018818378448486328,
"max_time": 0.0018818378448486328,
"current_concurrent": 0
},
"GET /": {
"count": 1,
"avg_time": 0.0030472278594970703,
"min_time": 0.0030472278594970703,
"max_time": 0.0030472278594970703,
"current_concurrent": 0
},
"GET /favicon.ico": {
"count": 1,
"avg_time": 0.002054452896118164,
"min_time": 0.002054452896118164,
"max_time": 0.002054452896118164,
"current_concurrent": 0
},
"GET /docs": {
"count": 1,
"avg_time": 0.004830598831176758,
"min_time": 0.004830598831176758,
"max_time": 0.004830598831176758,
"count": 2,
"avg_time": 0.003388047218322754,
"min_time": 0.0019888877868652344,
"max_time": 0.0047872066497802734,
"current_concurrent": 0
},
"GET /openapi.json": {
"count": 1,
"avg_time": 0.05776262283325195,
"min_time": 0.05776262283325195,
"max_time": 0.05776262283325195,
"count": 2,
"avg_time": 0.02791738510131836,
"min_time": 0.002294301986694336,
"max_time": 0.05354046821594238,
"current_concurrent": 0
}
},
"average_response_time": 0.021468718846638996,
"min_response_time": 0.0018129348754882812,
"max_response_time": 0.05776262283325195,
"average_response_time": 0.009942054748535156,
"min_response_time": 0.0018818378448486328,
"max_response_time": 0.05354046821594238,
"current_concurrent": 0,
"max_concurrent": 1,
"requests_per_second": 0.003289627426696439,
"uptime": 911.9573771953583,
"requests_per_second": 0.011523829992947607,
"uptime": 607.4369375705719,
"recent_errors": []
},
"timestamp": 1756392522.78795
"timestamp": 1756393318.7110236
}