-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.nvidia
More file actions
69 lines (50 loc) · 1.83 KB
/
Dockerfile.nvidia
File metadata and controls
69 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Pale Fire - Dockerfile.nvidia
# Custom Dockerfile for NVIDIA Quadro K2200 (sm_50) support
# Uses PyTorch 2.1.2 with CUDA 11.8 support which retains sm_50 compat
# Stage 1: Builder
FROM python:3.11-slim as builder
# Set working directory
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Install specific PyTorch version FIRST to ensure we get the right one
# We use --index-url to point to PyTorch's wheel repo for CUDA 11.8
RUN pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118 --no-cache-dir --user
# Copy requirements
COPY requirements.txt .
# Install other Python dependencies
# We use --no-deps for packages that might try to pull a newer torch, or just let pip handle it but prefer the cached wheel
RUN pip install --no-cache-dir --user -r requirements.txt
# Download spaCy model
RUN python -m spacy download en_core_web_sm
# Stage 2: Runtime
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy Python packages from builder
COPY --from=builder /root/.local /root/.local
# Copy spaCy model from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages/en_core_web_sm* /usr/local/lib/python3.11/site-packages/
# Make sure scripts in .local are usable
ENV PATH=/root/.local/bin:$PATH
# Copy application files
COPY . .
# Create necessary directories
RUN mkdir -p logs data
# Set env vars
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Expose ports
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Default command
CMD ["python", "api.py"]