Repository navigation
Expand file tree
/
Copy pathDockerfile.a3
More file actions
148 lines (135 loc) · 7.98 KB
/
Copy pathDockerfile.a3
File metadata and controls
148 lines (135 loc) · 7.98 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is a part of the vllm-ascend project.
#
FROM swr.cn-north-12.myhuaweicloud.com/atlas_inference/cann:9.2.0_20261022115200-a3-ubuntu22.04-py3.12
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /workspace
# Install clang-15 (for triton-ascend)
RUN apt-get update -y && \
apt-get install -y git vim wget curl protobuf-compiler libprotobuf-dev net-tools gcc g++ cmake numactl libnuma-dev libibverbs-dev libhiredis-dev clang-15 && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 20 && \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 20 && \
rm -rf /var/cache/apt/* && \
rm -rf /var/lib/apt/lists/*
# Install modelscope (for fast download) and ray (for multinode)
RUN python3 -m pip install 'modelscope<1.38' 'ray>=2.47.1,<=2.48.0' 'protobuf>3.20.0' && \
python3 -m pip cache purge
# Install vLLM
ARG VLLM_REPO=https://github.com/vllm-project/vllm.git
ARG VLLM_TAG=v0.31.0
ARG VLLM_COMMIT=""
RUN if [ -n "$VLLM_COMMIT" ]; then \
git init /vllm-workspace/vllm && \
git -C /vllm-workspace/vllm fetch --depth 1 $VLLM_REPO "$VLLM_COMMIT" && \
git -C /vllm-workspace/vllm checkout FETCH_HEAD; \
else \
git clone --depth 1 -b $VLLM_TAG $VLLM_REPO /vllm-workspace/vllm; \
fi
# In x86, triton will be installed by vllm. But in Ascend, triton doesn't work correctly. we need to uninstall it.
ARG PYTORCH_INDEX_URL="https://download.pytorch.org/whl/cpu/"
RUN VLLM_TARGET_DEVICE="empty" python3 -m pip install -e /vllm-workspace/vllm/[audio] --extra-index-url ${PYTORCH_INDEX_URL} && \
python3 -m pip uninstall -y triton && \
python3 -m pip cache purge
# Install vllm-ascend
# Dependency versions used by the vllm-ascend build.
ARG SOC_VERSION="ascend910_9391"
ENV DEBIAN_FRONTEND=noninteractive
ENV SOC_VERSION=$SOC_VERSION \
TASK_QUEUE_ENABLE=1 \
OMP_NUM_THREADS=1
COPY . /vllm-workspace/vllm-ascend/
ARG ASCEND_INDEX_URL="https://mirrors.huaweicloud.com/ascend/repos/pypi"
ARG COMPILE_CUSTOM_KERNELS=1
RUN export PIP_EXTRA_INDEX_URL="${ASCEND_INDEX_URL}" && \
export VLLM_BATCH_INVARIANT=1 && \
source /usr/local/Ascend/ascend-toolkit/set_env.sh && \
source /usr/local/Ascend/nnal/atb/set_env.sh && \
python3 -m pip install -e /vllm-workspace/vllm-ascend/ --extra-index-url ${PYTORCH_INDEX_URL} && \
python3 -m pip uninstall -y triton triton-ascend && \
python3 -m pip install concurrent-log-handler && \
python3 -m pip cache purge
# Install _rust_tool_parser for the Rust frontend.
# The default toolchain is read from vllm's rust-toolchain.toml (falling back
# to stable).
ENV PATH="/root/.cargo/bin:$PATH"
RUN cd /vllm-workspace/vllm && \
export PROTOC_INCLUDE=/usr/include && \
python3 -m pip install -r requirements/build/rust.txt && \
bash tools/build_rust.sh
# Append `libascend_hal.so` path (devlib) to LD_LIBRARY_PATH
RUN echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib" >> ~/.bashrc
# ===== Install pinned dependencies =====
# Update the pinned versions here.
ARG TARGETPLATFORM
ARG MEMCACHE_VERSION="1.3.0"
ARG MEMCACHE_DATE="20261022.5"
ARG MEMFABRIC_VERSION="1.3.0"
ARG MEMFABRIC_DATE="20261022.5"
ARG TORCH_NPU_VERSION="26.2.0"
ARG TORCH_NPU_DATE="20261015.5"
ARG FLA_VERSION="26.9.1+dev5cc6990"
ARG FLA_RELEASE_TAG="v26.9.1-20261020-020004"
ARG MOONCAKE_OBS_PREFIX="https://mindie.obs.cn-north-4.myhuaweicloud.com/buildtools/docker_images_tools/Mooncake/v0.3.14.rc1"
ARG HYBRID_OBS_BASE="https://obs-memfabric-hybrid.obs.cn-north-4.myhuaweicloud.com"
ARG TORCH_NPU_OBS_BASE="https://pytorch-package.obs.cn-north-4.myhuaweicloud.com"
ARG TRITON_ASCEND_URL_BASE="https://ascend-triton-open.obs.cn-north-4.myhuaweicloud.com/triton-ascend"
ARG TRITON_ASCEND_VERSION="20261019175332"
ARG TRITON_ASCEND_PACKAGE_VERSION="3.6.0"
RUN case "${TARGETPLATFORM:-$(uname -m)}" in \
"linux/amd64"|"x86_64") \
ARCH_SUFFIX="x86_64"; \
TRITON_ASCEND_URL="${TRITON_ASCEND_URL_BASE}/${TRITON_ASCEND_VERSION}/triton_ascend-${TRITON_ASCEND_PACKAGE_VERSION}-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl"; \
MEMFABRIC_URL="${HYBRID_OBS_BASE}/mf/release/1.3/${MEMFABRIC_DATE}/memfabric_hybrid-${MEMFABRIC_VERSION}-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl"; \
MEMCACHE_URL="${HYBRID_OBS_BASE}/memcache/release/1.3/${MEMCACHE_DATE}/memcache_hybrid-${MEMCACHE_VERSION}-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl"; \
MOONCAKE_WHL="mooncake_transfer_engine-0.3.13-cp312-cp312-manylinux_2_35_x86_64.whl"; \
FLA_WHL="flash_linear_attention_npu_a3-${FLA_VERSION}-py3-none-manylinux_2_34_x86_64.whl"; \
FLA_SHA256="a21fcb404405bfe44aef1a05beaa04c4e543f05749abf8cedde091dc409ccf1f" ;; \
"linux/arm64"|"aarch64") \
ARCH_SUFFIX="aarch64"; \
TRITON_ASCEND_URL="${TRITON_ASCEND_URL_BASE}/${TRITON_ASCEND_VERSION}/triton_ascend-${TRITON_ASCEND_PACKAGE_VERSION}-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl"; \
MEMFABRIC_URL="${HYBRID_OBS_BASE}/mf/release/1.3/${MEMFABRIC_DATE}/memfabric_hybrid-${MEMFABRIC_VERSION}-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl"; \
MEMCACHE_URL="${HYBRID_OBS_BASE}/memcache/release/1.3/${MEMCACHE_DATE}/memcache_hybrid-${MEMCACHE_VERSION}-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl"; \
MOONCAKE_WHL="mooncake_transfer_engine-0.3.13-cp312-cp312-manylinux_2_35_aarch64.whl"; \
FLA_WHL="flash_linear_attention_npu_a3-${FLA_VERSION}-py3-none-manylinux_2_34_aarch64.whl"; \
FLA_SHA256="db137e15852a395adca3d54aeeaac68f931a119b4953f0388c2694245ed9aa98" ;; \
*) echo "Unsupported platform: ${TARGETPLATFORM:-$(uname -m)}" && exit 1 ;; \
esac && \
source /usr/local/Ascend/ascend-toolkit/set_env.sh && \
# Install triton-ascend
echo "Install triton-ascend..." && \
python3 -m pip install "$TRITON_ASCEND_URL" && \
# Install mooncake-transfer-engine, memfabric_hybrid and memcache_hybrid
wget -q --no-check-certificate "${MOONCAKE_OBS_PREFIX}/${MOONCAKE_WHL}" -P /tmp && \
python3 -m pip install "$MEMFABRIC_URL" "$MEMCACHE_URL" /tmp/${MOONCAKE_WHL} --force-reinstall --no-deps && \
# Install memfabric_hybrid kernels (A3/A5)
case "${SOC_VERSION:-}" in \
ascend950dt_9582) TORCH_DEVICE_BACKEND_AUTOLOAD=0 mfcli kernel install --soc-version A5 ;; \
ascend910_9391) TORCH_DEVICE_BACKEND_AUTOLOAD=0 mfcli kernel install --soc-version A3 ;; \
esac && \
# Install flash-linear-attention-npu
wget --quiet "${GIT_PROXY:-}https://github.com/flashserve/flash-linear-attention-npu/releases/download/${FLA_RELEASE_TAG}/${FLA_WHL}" -O /tmp/${FLA_WHL} && \
echo "${FLA_SHA256} /tmp/${FLA_WHL}" | sha256sum --check && \
python3 -m pip install --force-reinstall --no-deps /tmp/${FLA_WHL} && \
# Install torch-npu
mkdir -p /tmp/torch_npu && \
wget -q --retry-connrefused --tries=5 --timeout=30 --waitretry=10 \
-O /tmp/torch_npu/torch_npu.tar.gz \
"${TORCH_NPU_OBS_BASE}/pta/Daily/v2.10.0-${TORCH_NPU_VERSION}/${TORCH_NPU_DATE}/pytorch_v2.10.0-${TORCH_NPU_VERSION}_py312.tar.gz" && \
tar -xzf /tmp/torch_npu/torch_npu.tar.gz -C /tmp/torch_npu && \
python3 -m pip install /tmp/torch_npu/torch_npu-2.10.0*_"${ARCH_SUFFIX}".whl --extra-index-url https://download.pytorch.org/whl/cpu/ && \
rm -rf /tmp/torch_npu /tmp/${MOONCAKE_WHL} /tmp/${FLA_WHL} && \
python3 -m pip cache purge
CMD ["/bin/bash"]