From bb559dff6ae2799831b439aca89e6537ae324d06 Mon Sep 17 00:00:00 2001 From: sujong Date: Wed, 9 Apr 2025 15:01:19 +0900 Subject: [PATCH] Add Dockerfile and docker-compose setup for containerized usage --- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ docker-compose.yaml | 21 +++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..fc107aa9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM pytorch/pytorch:2.5.1-cuda12.1-cudnn9-devel + +# Prevent Python from buffering stdout/stderr +ENV PYTHONUNBUFFERED=1 +ENV DEBIAN_FRONTEND=noninteractive + +# Install essential system packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + ffmpeg \ + libavutil-dev \ + libavcodec-dev \ + libavformat-dev \ + libswscale-dev \ + pkg-config \ + build-essential \ + libffi-dev \ + wget \ + python3-opencv && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /workspace +COPY . . + +# Install Python packages +RUN pip install --upgrade pip setuptools && \ + pip install -r requirements.txt && \ + pip install hydra-core iopath decord + +# Download SAM2 model checkpoints +RUN cd sam2/checkpoints && chmod +x download_ckpts.sh && ./download_ckpts.sh + +# Default command +CMD ["/bin/bash"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..5891bd03 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,21 @@ +version: "3.9" + +services: + samurai: + build: + context: . + dockerfile: Dockerfile + container_name: samurai_dev + runtime: nvidia # Enable GPU access + environment: + - NVIDIA_VISIBLE_DEVICES=all # Expose all GPUs + - NVIDIA_DRIVER_CAPABILITIES=compute,utility,video + volumes: + - .:/workspace # Mount project directory + working_dir: /workspace # Set working directory inside container + stdin_open: true # Keep STDIN open for interactive use + tty: true # Allocate a pseudo-TTY + ipc: host # Share IPC namespace (for performance) + ulimits: + memlock: -1 # Disable memory locking limits + stack: 67108864 # Increase stack size to 64MB