Add torch (CPU) to evalscope-complete-py312 Docker image for tokenizer support
- Install torch==2.1.2 (CPU wheel) so AutoTokenizer can load models like DeepSeek-V4-Flash without runtime import errors. - Keep numpy==1.26.4 pinned; torch 2.1.x is compatible with it. - Verify torch and transformers AutoTokenizer import in the image build. Note: tools/docker/* is gitignored, so this file is force-added.
This commit is contained in:
parent
c3b7f340e8
commit
a194724bcb
163
tools/docker/Dockerfile.py312
Normal file
163
tools/docker/Dockerfile.py312
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
# EvalScope Benchmark Docker Image (Python 3.12)
|
||||||
|
# 除 swe_bench 系列外,其他 benchmark 均可直接运行
|
||||||
|
# 使用国内镜像源解决网络问题
|
||||||
|
# 基于 python:3.12-slim,在容器内重新安装所有依赖
|
||||||
|
|
||||||
|
FROM python:3.12-slim-bookworm
|
||||||
|
|
||||||
|
LABEL maintainer="evalscope-benchmark"
|
||||||
|
LABEL description="EvalScope benchmark environment with Python 3.12, all dependencies including swe_bench"
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV PIP_NO_CACHE_DIR=1
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
|
||||||
|
# 配置 apt 使用清华镜像源
|
||||||
|
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
||||||
|
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free' > /etc/apt/sources.list && \
|
||||||
|
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-free' >> /etc/apt/sources.list && \
|
||||||
|
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free' >> /etc/apt/sources.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
git wget curl ca-certificates \
|
||||||
|
vim \
|
||||||
|
build-essential libssl-dev libffi-dev zlib1g-dev \
|
||||||
|
docker.io \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# 配置 pip 使用清华镜像源
|
||||||
|
RUN mkdir -p /root/.config/pip && \
|
||||||
|
cat > /root/.config/pip/pip.conf << 'EOF'
|
||||||
|
[global]
|
||||||
|
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
trusted-host = pypi.tuna.tsinghua.edu.cn
|
||||||
|
timeout = 120
|
||||||
|
retries = 5
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 升级 pip
|
||||||
|
RUN pip install --upgrade pip setuptools wheel
|
||||||
|
|
||||||
|
# 先固定 numpy/scipy 版本(bfcl-eval 要求 numpy==1.26.4;新版 scipy 要求 numpy>=2.0)
|
||||||
|
RUN pip install numpy==1.26.4 scipy==1.13.1
|
||||||
|
|
||||||
|
# 安装 evalscope 依赖(先安装依赖,再用本地源码覆盖)
|
||||||
|
RUN pip install \
|
||||||
|
openai pandas pyyaml requests tqdm \
|
||||||
|
tiktoken transformers \
|
||||||
|
scikit-learn matplotlib seaborn plotly \
|
||||||
|
jieba nltk rouge-score sacrebleu \
|
||||||
|
sympy latex2sympy2_extended pillow \
|
||||||
|
docker pexpect pytest \
|
||||||
|
tabulate rich jsonlines jsonschema \
|
||||||
|
langdetect word2number zhconv \
|
||||||
|
modelscope pydantic overrides \
|
||||||
|
more_itertools pylatexenc \
|
||||||
|
rouge-chinese markdown \
|
||||||
|
editdistance dotenv docstring_parser \
|
||||||
|
colorlog
|
||||||
|
|
||||||
|
# 安装 torch(CPU 版即可,主要用于 tokenizer 加载与部分 benchmark 的 tensor 操作)
|
||||||
|
# 固定 numpy==1.26.4 已在前一步完成,torch 2.1.x 与该版本兼容
|
||||||
|
RUN pip install torch==2.1.2 --index-url https://download.pytorch.org/whl/cpu 2>/dev/null || \
|
||||||
|
pip install torch==2.1.2 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 sandbox 支持(ms-sandbox 等)
|
||||||
|
RUN pip install evalscope[sandbox] 2>/dev/null || \
|
||||||
|
pip install ms-sandbox 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 terminal_bench 依赖 (harbor)
|
||||||
|
RUN pip install "harbor>=0.8.0,<1.0.0" 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 tau2-bench 依赖(不安装 torch/vllm,避免镜像过大)
|
||||||
|
RUN pip install \
|
||||||
|
fastapi uvicorn psutil loguru \
|
||||||
|
litellm tenacity deepdiff addict toml 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 tau2-bench 依赖
|
||||||
|
RUN pip install git+https://github.com/sierra-research/tau2-bench@v0.2.0 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 bigcodebench 核心评估依赖(不安装 torch/vllm/accelerate)
|
||||||
|
RUN pip install \
|
||||||
|
tempdir termcolor wget \
|
||||||
|
gradio-client 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 bfcl_v3 依赖(--no-deps 避免 torch,再手动补必要依赖)
|
||||||
|
# tree-sitter 必须固定版本,bfcl-eval 要求 tree_sitter==0.21.3,
|
||||||
|
# 否则 Language() API 不兼容会报错
|
||||||
|
RUN pip install --no-deps bfcl-eval==2025.10.27.1 2>/dev/null || true
|
||||||
|
RUN pip install \
|
||||||
|
anthropic cohere==5.18.0 datamodel-code-generator==0.25.7 \
|
||||||
|
faiss-cpu==1.11.0 google-genai==1.24.0 mistralai==1.7.0 \
|
||||||
|
networkx==3.3 google-search-results \
|
||||||
|
rank_bm25 html2text boto3 qwen-agent writer-sdk \
|
||||||
|
tree-sitter==0.21.3 \
|
||||||
|
tree-sitter-python==0.21.0 \
|
||||||
|
tree-sitter-javascript==0.21.4 \
|
||||||
|
tree-sitter-java==0.21.0 \
|
||||||
|
pathlib 2>/dev/null || true
|
||||||
|
# sentence-transformers 会强制拉 torch(~2GB+),如运行 bfcl_v3 的 embedding 类任务需手动安装
|
||||||
|
|
||||||
|
# 安装 soundfile / openpyxl
|
||||||
|
RUN pip install soundfile openpyxl 2>/dev/null || true
|
||||||
|
|
||||||
|
# 安装 SWE-bench 支持
|
||||||
|
RUN pip install evalscope[swe_bench] 2>/dev/null || \
|
||||||
|
pip install swebench==4.1.0 2>/dev/null || true
|
||||||
|
|
||||||
|
# 创建 workspace
|
||||||
|
RUN mkdir -p /opt/evalscope
|
||||||
|
WORKDIR /opt/evalscope
|
||||||
|
|
||||||
|
# 复制本地 evalscope 源码、bash 脚本和 tau2-bench
|
||||||
|
# 注意:tau2-bench 在仓库里位于 tools/tau2-bench/
|
||||||
|
COPY evalscope/ /opt/evalscope/evalscope/
|
||||||
|
COPY bash/ /opt/evalscope/bash/
|
||||||
|
COPY tau2-bench/ /opt/evalscope/tools/tau2-bench/
|
||||||
|
|
||||||
|
# 用本地源码安装 evalscope(editable mode)
|
||||||
|
RUN pip install -e /opt/evalscope/evalscope/
|
||||||
|
|
||||||
|
# 安装本地 tau2-bench 到 Python 环境(先装依赖,避免与 bfcl-eval 冲突)
|
||||||
|
RUN pip install \
|
||||||
|
rich tabulate fastapi uvicorn pandas psutil loguru \
|
||||||
|
docstring-parser "litellm>=1.80.15,<1.82.7" "tenacity>=9.0.0" \
|
||||||
|
deepdiff addict PyYAML toml python-dotenv typer requests httpx \
|
||||||
|
2>/dev/null || true
|
||||||
|
RUN pip install -e /opt/evalscope/tools/tau2-bench/ --no-deps 2>/dev/null || true
|
||||||
|
|
||||||
|
# 最终固定 numpy/scipy 版本,确保 bfcl-eval 兼容且 scipy 不与 numpy 1.26.4 冲突
|
||||||
|
RUN pip install --force-reinstall numpy==1.26.4 scipy==1.13.1 2>/dev/null || true
|
||||||
|
|
||||||
|
# 设置权限
|
||||||
|
RUN chmod -R +x /opt/evalscope/bash/*.py 2>/dev/null || true
|
||||||
|
|
||||||
|
# 创建输出目录
|
||||||
|
RUN mkdir -p /opt/evalscope/output \
|
||||||
|
/opt/evalscope/output_limit100 \
|
||||||
|
/opt/evalscope/output_swe_bench \
|
||||||
|
/opt/evalscope/datasets
|
||||||
|
|
||||||
|
# 验证安装
|
||||||
|
RUN python -c "import evalscope; print('evalscope ok')" && \
|
||||||
|
python -c "import evalscope.api.agent; print('evalscope.api.agent ok')" && \
|
||||||
|
python -c "import openai; print('openai ok')" && \
|
||||||
|
python -c "import pandas; print('pandas ok')" && \
|
||||||
|
python -c "import numpy; print('numpy ok')" && \
|
||||||
|
python -c "import torch; print('torch ok')" && \
|
||||||
|
python -c "from transformers import AutoTokenizer; print('transformers tokenizer ok')" && \
|
||||||
|
python -c "import docker; print('docker ok')" && \
|
||||||
|
python -c "import harbor; print('harbor ok')" && \
|
||||||
|
python -c "import tau2; print('tau2 ok')" && \
|
||||||
|
python -c "from tau2.runner.batch import run_single_task; print('tau2 runner ok')" && \
|
||||||
|
python -c "import bfcl_eval; print('bfcl_eval ok')" && \
|
||||||
|
python -c "import soundfile; print('soundfile ok')" && \
|
||||||
|
python -c "import openpyxl; print('openpyxl ok')" && \
|
||||||
|
docker --version
|
||||||
|
|
||||||
|
# 设置 PYTHONPATH,确保 editable install 的 evalscope 能被正确加载
|
||||||
|
ENV PYTHONPATH=/opt/evalscope/evalscope
|
||||||
|
|
||||||
|
# 默认命令
|
||||||
|
CMD ["/bin/bash"]
|
||||||
Loading…
x
Reference in New Issue
Block a user