bone_2026/Dockerfile_cuda

72 lines
2.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# DXA Quality Assessment - Docker Container (GPU / CUDA)
# Build: docker build -f Dockerfile_cuda -t dxa-quality-cuda .
# Run: docker run --gpus all -v /path/to/data:/data -v /path/to/models:/app/models \
# -p 8000:8000 dxa-quality-cuda
# Base image with GPU support
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
# Неинтерактивный режим для apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
python3.10 \
python3-pip \
python3.10-dev \
python3.10-venv \
build-essential \
ninja-build \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Обновляем pip и ставим свежий meson (0.64.0+) — ДО всех Python-пакетов
RUN pip3 install --no-cache-dir --upgrade pip "meson>=0.64.0"
WORKDIR /app
# --- PyTorch под CUDA 11.8 (ставим отдельно, чтобы не тянулся CUDA 12.6) ---
RUN pip3 install --no-cache-dir \
torch==2.8.0 torchvision==0.23.0 \
--index-url https://download.pytorch.org/whl/cu118
# --- Остальные зависимости ---
# Список версий один на оба образа: requirements.txt. Уже установленный torch
# pip не переустановит — версия из cu118 удовлетворяет требованию.
COPY requirements.txt ./
RUN pip3 install --no-cache-dir -r requirements.txt
# --- Код приложения ---
COPY src ./src
COPY run.sh ./run.sh
RUN chmod +x ./run.sh
RUN mkdir -p models
# Smoke-проверка импорта: падает на сборке, если зависимость недоступна или
# модуль не найден, вместо тихой 500-й в рантайме. Чекпоинт здесь не читается.
RUN python3 -c "import src.main; print('app import ok')"
# --- Проверка статики для офлайн-работы ---
# Tailwind и FontAwesome лежат в src/api/static, обращений к CDN быть не должно.
RUN python3 -c "import os; \
files=['src/api/static/vendor/tailwind.js','src/api/static/vendor/fontawesome.css', \
'src/api/static/webfonts/fa-solid-900.woff2']; \
missing=[f for f in files if not os.path.exists(f)]; \
assert not missing, f'missing frontend assets: {missing}'; \
print('frontend assets ok')"
# Expose API port
EXPOSE 8000
# Environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
DXA_MODEL_PATH=/app/models/dxa_model.pth
# Default command
CMD ["python3", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]