Commit 7b83aaca by 江名洋

build(docker): 从源码编译 NumPy 以兼容旧 CPU

1 parent 43c910f2
FROM python:3.11-slim FROM python:3.11-slim
# 兼容旧 CPU 的 NumPy 环境设置 # 兼容旧 CPU 的环境设置
ENV OPENBLAS_CORETYPE=Haswell ENV OPENBLAS_CORETYPE=Haswell
# PyPI 镜像加速(清华源) # PyPI 镜像加速(清华源)
...@@ -8,9 +8,14 @@ ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple ...@@ -8,9 +8,14 @@ ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
WORKDIR /app WORKDIR /app
# 安装编译工具链(用于源码编译 numpy,兼容旧 CPU)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ gfortran libopenblas-dev liblapack-dev \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt . COPY requirements.txt .
# 强制先装 NumPy 1.x 避免 pip resolver 拉到 2.x (要求 x86-64-v2 指令集) # 从源码编译 numpy 1.x,避免预编译 wheel 使用 x86-64-v2 指令集
RUN pip install --no-cache-dir numpy==1.26.4 RUN pip install --no-cache-dir --no-binary=numpy numpy==1.26.4
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!