olmOCR-docker镜像制作
总体参考文档: https://www.cnblogs.com/chenkuang/p/18842466从魔塔社区下载对应的两个大模型
modelscope download --model allenai/olmOCR-7B-0225-preview --local_dir ./model/olmOCR
modelscope download --model Qwen/Qwen2.5-VL-7B-Instruct --local_dir ./model/QwenVL
修改pip源 RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
单独下载flashinfer-0.1.6 再copy到镜像中单独安装
增加ui https://blog.csdn.net/weixin_66401877/article/details/146355792
修改后的dockerfile
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04
# Avoid interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
poppler-utils \
wget \
git \
build-essential \
python3-pip \
curl \
software-properties-common \
&& add-apt-repository multiverse \
&& apt-get update \
&& apt-get install -y ttf-mscorefonts-installer \
fonts-crosextra-caladea fonts-crosextra-carlito gsfonts lcdf-typetools
# Accept Microsoft font license terms
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
# Install Miniconda
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh \
&& bash /tmp/miniconda.sh -b -p /opt/conda \
&& rm /tmp/miniconda.sh
# Set conda in PATH
ENV PATH="/opt/conda/bin:${PATH}"
# Create conda environment
RUN conda create -y -n olmocr python=3.11 \
&& echo "source activate olmocr" > ~/.bashrc
# Activate conda environment and install olmocr
SHELL ["/bin/bash", "-c"]
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
COPY olmocr /olmocr
RUN source activate olmocr \
&& cd /olmocr \
&& pip install -e .
# Install sglang with flashinfer for GPU
RUN source activate olmocr
RUN pip install sgl-kernel==0.0.3.post1 --force-reinstall --no-deps
# 尝试单独安装 flashinfer
COPY whl /whl
# 激活 conda 环境并安装 flashinfer
RUN source activate olmocr \
&& pip install /whl/flashinfer-0.1.6+cu124torch2.4-cp311-cp311-linux_x86_64.whl
# 手动指定 flashinfer 版本
RUN source activate olmocr \
&& pip install flashinfer==0.1.6 \
RUN source activate olmocr \
&&pip install "sglang[all]==0.4.2" --use-feature=fast-deps
# Install Gradio
RUN source activate olmocr \
&& pip install gradio
RUN source activate olmocr \
&& pip install pandas
# Copy the Gradio app
#COPY app.py /app/app.py
# Expose port for Gradio
EXPOSE 19851
# Set working directory
WORKDIR /olmocr
# Startup command
CMD ["bash", "-c", "source activate olmocr && python app.py"]