Commit 65798994 authored by dongjw's avatar dongjw
Browse files

update Dockerfile

parent 56a18ad0
FROM node:20.16.0 as web_compile FROM pytorch/pytorch:2.5.1-cuda12.1-cudnn9-devel as compile_server
WORKDIR /home
RUN <<EOF
git clone https://github.com/kvcache-ai/ktransformers.git &&
cd ktransformers/ktransformers/website/ &&
npm install @vue/cli &&
npm run build &&
rm -rf node_modules
EOF
# 设置代理
ENV http_proxy=http://127.0.0.1:20181
ENV https_proxy=http://127.0.0.1:20181
ENV all_proxy=http://127.0.0.1:20181
FROM pytorch/pytorch:2.5.1-cuda12.1-cudnn9-devel as compile_server
ARG CPU_INSTRUCT=NATIVE ARG CPU_INSTRUCT=NATIVE
# 设置工作目录和 CUDA 路径
WORKDIR /workspace WORKDIR /workspace
ENV CUDA_HOME /usr/local/cuda ENV CUDA_HOME=/usr/local/cuda
COPY --from=web_compile /home/ktransformers /workspace/ktransformers
RUN <<EOF
apt update -y && apt install -y --no-install-recommends \
# 安装依赖
RUN apt update -y
RUN apt install -y --no-install-recommends \
libtbb-dev \
libssl-dev \
libcurl4-openssl-dev \
libaio1 \
libaio-dev \
libfmt-dev \
libgflags-dev \
zlib1g-dev \
patchelf \
git \ git \
wget \ wget \
vim \ vim \
gcc \ gcc \
g++ \ g++ \
cmake && cmake
rm -rf /var/lib/apt/lists/* && # 拷贝代码
cd ktransformers && RUN git clone https://github.com/kvcache-ai/ktransformers.git
git submodule init && # 清理 apt 缓存
git submodule update && RUN rm -rf /var/lib/apt/lists/*
pip install --upgrade pip &&
pip install ninja pyproject numpy cpufeature && # 进入项目目录
pip install flash-attn && WORKDIR /workspace/ktransformers
CPU_INSTRUCT=${CPU_INSTRUCT} KTRANSFORMERS_FORCE_BUILD=TRUE TORCH_CUDA_ARCH_LIST="8.0;8.6;8.7;8.9;9.0+PTX" pip install . --no-build-isolation --verbose && RUN git checkout work-concurrent
pip cache purge && # 初始化子模块
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/conda/lib/ RUN git submodule update --init --recursive
EOF
# 升级 pip
RUN pip install --upgrade pip
# 安装构建依赖
RUN pip install ninja pyproject numpy cpufeature aiohttp zmq openai
# 安装 flash-attn(提前装可以避免后续某些编译依赖出错)
RUN pip install flash-attn
# 安装 ktransformers 本体(含编译)
RUN CPU_INSTRUCT=${CPU_INSTRUCT} \
USE_BALANCE_SERVE=1 \
KTRANSFORMERS_FORCE_BUILD=TRUE \
TORCH_CUDA_ARCH_LIST="8.0;8.6;8.7;8.9;9.0+PTX" \
pip install . --no-build-isolation --verbose
RUN pip install third_party/custom_flashinfer/
# 清理 pip 缓存
RUN pip cache purge
# 拷贝 C++ 运行时库
RUN cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/conda/lib/
# 保持容器运行(调试用)
ENTRYPOINT ["tail", "-f", "/dev/null"] ENTRYPOINT ["tail", "-f", "/dev/null"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment