forked from open-compass/opencompass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
130 lines (102 loc) · 3.52 KB
/
Dockerfile
File metadata and controls
130 lines (102 loc) · 3.52 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Multi-stage build for OpenCompass
# Build arguments
ARG PYTHON_VERSION=3.10
ARG BUILD_DATE
ARG VERSION
ARG REVISION
# Stage 1: Base image with system dependencies
FROM python:${PYTHON_VERSION}-slim AS base
# Labels
LABEL org.opencontainers.image.created="${BUILD_DATE}"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="${REVISION}"
LABEL org.opencontainers.image.title="OpenCompass"
LABEL org.opencontainers.image.description="A unified evaluation platform for large language models"
LABEL org.opencontainers.image.source="https://github.com/open-compass/opencompass"
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
gcc \
g++ \
make \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libglu1-mesa \
libgl1 \
libglew-dev \
libosmesa6-dev \
libglu1-mesa-dev \
libgl1-mesa-dev \
libglfw3 \
libglfw3-dev \
wget \
curl \
vim \
&& rm -rf /var/lib/apt/lists/*
# Stage 2: Builder stage for dependencies
FROM base AS builder
WORKDIR /tmp
# Copy requirements files
COPY requirements/ /tmp/requirements/
# Install PyTorch (CPU version for CI/CD)
# For CUDA support, change the index URL to the appropriate CUDA version
RUN pip install --no-cache-dir torch>=1.13.1 --index-url https://download.pytorch.org/whl/cpu
# Install base runtime requirements
RUN pip install --no-cache-dir -r requirements/runtime.txt
# Update git config to foce use HTTPS urls over SSH
RUN git config --global url."https://github.com/".insteadOf git@github.com:
# Install API requirements (optional)
RUN pip install --no-cache-dir -r requirements/api.txt || true
RUN pip install --no-cache-dir -r requirements/extra.txt || true
RUN pip install --no-cache-dir latex2sympy2-extended
# Stage 3: Final runtime image
FROM base AS runtime
# Set working directory
WORKDIR /workspace
# Copy Python packages from builder
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy the entire project
COPY . /workspace/
# Install OpenCompass in development mode
RUN pip install math_verify latex2sympy2_extended
RUN pip install -e .
# Download NLTK data
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab')"
# Create directories for data and outputs
RUN mkdir -p /workspace/data /workspace/outputs /workspace/cache
# Set environment variables
ENV PYTHONPATH=/workspace:$PYTHONPATH
ENV TOKENIZERS_PARALLELISM=false
ENV HF_HOME=/workspace/cache
ENV TRANSFORMERS_CACHE=/workspace/cache
ENV TORCH_HOME=/workspace/cache
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose port for potential API services
EXPOSE 8000
# Expose Jupyter port
EXPOSE 8888
# Set entrypoint
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# Default command
CMD ["help"]
# Alternative Dockerfile for development with all optional dependencies
# Uncomment the following to build a development image with all features
# FROM runtime as dev
#
# # Install development and testing requirements
# RUN pip install --no-cache-dir -r requirements/dev.txt || true
# RUN pip install --no-cache-dir -r requirements/test.txt || true
#
# # Install optional inference backends (choose one)
# # RUN pip install --no-cache-dir -r requirements/lmdeploy.txt
# # RUN pip install --no-cache-dir -r requirements/vllm.txt
#
# # Install extra evaluation tools
#
# CMD ["bash"]