|
| 1 | +# VideoAnnotator Docker Image - Legacy GPU (GTX 10xx / CUDA 11.x) |
| 2 | +# |
| 3 | +# Purpose: |
| 4 | +# - Designed for older GPUs (eg. GTX 1060) that are best matched with CUDA 11.x |
| 5 | +# - Keeps heavy steps optional (SKIP_IMAGE_UV_SYNC / SKIP_TORCH_INSTALL) so builders can |
| 6 | +# choose to perform network operations at container runtime instead of at build time. |
| 7 | +# |
| 8 | +# Usage (build): |
| 9 | +# docker build -f Dockerfile.oldgpu -t videoannotator:oldgpu . |
| 10 | +# |
| 11 | +# Usage (run): |
| 12 | +# docker run --gpus all --rm -p 18011:18011 -v ${PWD}/data:/app/data videoannotator:oldgpu |
| 13 | + |
| 14 | +# Choose a CUDA 11.x runtime image compatible with older GPUs/drivers |
| 15 | +FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04 |
| 16 | + |
| 17 | +SHELL ["/bin/bash","-lc"] |
| 18 | + |
| 19 | +# Install core system packages and graphics libs commonly required by some pipelines |
| 20 | +RUN apt-get update && apt-get install -y \ |
| 21 | + curl python3 python3-venv python3-pip git git-lfs \ |
| 22 | + libgl1-mesa-dri libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \ |
| 23 | + && rm -rf /var/lib/apt/lists/* |
| 24 | + |
| 25 | +# Ensure locale is generated so LANG=en_US.UTF-8 works inside the container |
| 26 | +RUN apt-get update && apt-get install -y locales \ |
| 27 | + && locale-gen en_US.UTF-8 \ |
| 28 | + && update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \ |
| 29 | + && rm -rf /var/lib/apt/lists/* |
| 30 | + |
| 31 | +# Export UTF-8 locale for all processes |
| 32 | +ENV LANG=en_US.UTF-8 |
| 33 | +ENV LC_ALL=en_US.UTF-8 |
| 34 | + |
| 35 | +# Initialize Git LFS |
| 36 | +RUN git lfs install |
| 37 | + |
| 38 | +# uv package manager (project standard) |
| 39 | +RUN curl -LsSf https://astral.sh/uv/install.sh | sh |
| 40 | +ENV PATH="/root/.local/bin:${PATH}" |
| 41 | + |
| 42 | +WORKDIR /app |
| 43 | + |
| 44 | +# Build args to allow skipping heavy network steps during image build |
| 45 | +ARG SKIP_IMAGE_UV_SYNC=true |
| 46 | +ARG SKIP_TORCH_INSTALL=true |
| 47 | + |
| 48 | +# Copy project files (exclude large model artifacts via .dockerignore) |
| 49 | +COPY . . |
| 50 | + |
| 51 | +# Copy local models / weights if you want them baked into the image (optional) |
| 52 | +# COPY models/ /app/models/ |
| 53 | +# COPY weights/ /app/weights/ |
| 54 | + |
| 55 | +# Install Python dependencies via uv (can be skipped at build time) |
| 56 | +RUN if [ "${SKIP_IMAGE_UV_SYNC}" != "true" ]; then uv sync --frozen --no-editable; else echo "[BUILD] Skipping uv sync at image build (SKIP_IMAGE_UV_SYNC=true)"; fi |
| 57 | + |
| 58 | +# Torch installation: keep this optional because CUDA and appropriate wheel sets can vary |
| 59 | +# Provide build args to install a matching wheel at build time. Example values are |
| 60 | +# for CUDA 11.3: TORCH_WHEEL="torch==1.13.1+cu113 torchvision==0.14.1+cu113 torchaudio==0.13.1+cu113" |
| 61 | +ARG TORCH_WHEEL="" |
| 62 | +ARG TORCH_INDEX_URL="https://download.pytorch.org/whl/cu113" |
| 63 | +RUN if [ "${SKIP_TORCH_INSTALL}" != "true" ] && [ -n "${TORCH_WHEEL}" ]; then \ |
| 64 | + echo "[BUILD] Installing torch wheels: ${TORCH_WHEEL}"; \ |
| 65 | + uv pip install ${TORCH_WHEEL} --index-url ${TORCH_INDEX_URL}; \ |
| 66 | + else \ |
| 67 | + echo "[BUILD] Skipping torch install (SKIP_TORCH_INSTALL=${SKIP_TORCH_INSTALL}, TORCH_WHEEL set: ${TORCH_WHEEL:+yes})"; \ |
| 68 | + fi |
| 69 | + |
| 70 | +# Quick smoke-check (optional) - this will only run if uv and Python are available |
| 71 | +RUN uv run python3 -c "import sys; print('[OLDGPU BUILD] Python:', sys.version.splitlines()[0])" |
| 72 | + |
| 73 | +ENV PYTHONUNBUFFERED=1 |
| 74 | +ENV CUDA_VISIBLE_DEVICES=0 |
| 75 | + |
| 76 | +# Create directories for mounted volumes |
| 77 | +RUN mkdir -p /app/data /app/output /app/logs |
| 78 | + |
| 79 | +EXPOSE 18011 |
| 80 | + |
| 81 | +CMD ["uv", "run", "python3", "api_server.py", "--log-level", "info", "--port", "18011"] |
0 commit comments