diff --git a/Dockerfile b/Dockerfile index 758d075cf3b64f3a8e5d861793930443442fd7cd..c70653247bb20132d166d147b71083f065c006ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,24 +100,6 @@ RUN set -ex && \ echo "Driver_Install_Mode=normal" >> /etc/ascend_install.info && \ echo "Driver_Install_Status=complete" >> /etc/ascend_install.info -RUN set -ex && \ - ARCH=$(uname -m) && \ - cd /root && \ - CANN_TOOLKIT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-toolkit_8.1.RC1_linux-${ARCH}.run && \ - CANN_KERNELS_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-kernels-910b_8.1.RC1_linux-${ARCH}.run && \ - CANN_NNRT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-nnrt_8.1.RC1_linux-${ARCH}.run && \ - wget --header="Referer: https://www.hiascend.com/" ${CANN_TOOLKIT_URL} -O Ascend-cann-toolkit.run --no-check-certificate && \ - wget --header="Referer: https://www.hiascend.com/" ${CANN_KERNELS_URL} -O Ascend-cann-kernels-910b.run --no-check-certificate && \ - wget --header="Referer: https://www.hiascend.com/" ${CANN_NNRT_URL} -O Ascend-cann-nnrt.run --no-check-certificate - -RUN set -ex && \ - cd /root && \ - chmod a+x *.run && \ - bash /root/Ascend-cann-toolkit.run --install -q && \ - bash /root/Ascend-cann-kernels-910b.run --install -q && \ - bash Ascend-cann-nnrt.run --install -q && \ - rm /root/*.run - RUN set -ex && \ echo "source /usr/local/Ascend/nnrt/set_env.sh" >> /root/.bashrc && \ echo "source /usr/local/Ascend/ascend-toolkit/set_env.sh" >> /root/.bashrc diff --git a/README.md b/README.md index d4ecb56715fc8ef0f5a98d17be16b1396b41e85b..cdbfc82bf833ae71f8361aec39c09befdb909ed2 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,14 @@ vllm-mindspore serve Qwen/Qwen3-8B 请查看[快速体验](https://www.mindspore.cn/vllm_mindspore/docs/zh-CN/master/getting_started/quick_start/quick_start.html)和[安装指南](https://www.mindspore.cn/vllm_mindspore/docs/zh-CN/master/getting_started/installation/installation.html)了解更多。 +## 镜像构建 + +可使用以下命令构建vLLM-MindSpore插件的配套Docker镜像,通过参数-a选择相应的NPU类型进行构建,`device_type`表示设备类型,`910b` 为Atlas A2系列,`310p` 为Atlas 300I Pro/Duo和Atlas 300V Pro系列,默认为 `910b`: + +```bash +bash build_image.sh -a device_type +``` + ## 贡献 请参考 [CONTRIBUTING](https://www.mindspore.cn/vllm_mindspore/docs/zh-CN/master/developer_guide/contributing.html) 文档了解更多关于开发环境搭建、功能测试以及 PR 提交规范的信息。 diff --git a/README_en.md b/README_en.md index 0c36856c835d5356724abd3dfee64d2e85fc3994..0c735522e9fb8c284f57c1a8e11b8eff29bc5e97 100644 --- a/README_en.md +++ b/README_en.md @@ -64,6 +64,14 @@ vllm-mindspore serve Qwen/Qwen3-8B Please refer to [Quick Start](https://www.mindspore.cn/vllm_mindspore/docs/en/master/getting_started/quick_start/quick_start.html) and [Installation](https://www.mindspore.cn/vllm_mindspore/docs/en/master/getting_started/installation/installation.html) for more details. +## Image build + +A Docker image for vLLM-MindSpore Plugin deployment can be built using the following command. Use the -a parameter to specify the corresponding Ascend device type. `device_type` indicates the device type: `910b` refers to the Atlas A2 series, and `310p` refers to the Atlas 300I Pro/Duo or Atlas 300V Pro series, default is `910b`: + +```bash +bash build_image.sh -a device_type +``` + ## Contributing Please read [CONTRIBUTING](https://www.mindspore.cn/vllm_mindspore/docs/en/master/developer_guide/contributing.html) for details on setting up development environments, testing functions, and submitting PR. diff --git a/build_image.sh b/build_image.sh index 2494784fce152cb19c54b8704f8155c4c0d1e29b..b596505c4465df1afff581554846fe43c6a84cd8 100644 --- a/build_image.sh +++ b/build_image.sh @@ -16,13 +16,49 @@ # limitations under the License. set -euo pipefail +TARGET="910b" +ARCH=$(uname -m) + +build_usage() { + echo "Usage: $0 [-a 910b|310p]" + exit 1 +} + +while getopts "a:h" opt; do + case $opt in + a) + if [[ "$OPTARG" == "910b" || "$OPTARG" == "310p" ]]; then + TARGET="$OPTARG" + else + echo "Error: -a must be '910b' or '310p', got '$OPTARG'" >&2 + exit 1 + fi + ;; + h) + build_usage + ;; + \?|:) + build_usage + ;; + esac +done + +shift $((OPTIND - 1)) +if [ $# -gt 0 ]; then + echo "Error: invalid input $@" + build_usage +fi readonly IMAGE_TAG="vllm_ms_$(date +%Y%m%d)" log() { - echo "========= $*" + echo "===== Build image for ${TARGET} ==== $*" } +CANN_TOOLKIT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-toolkit_8.1.RC1_linux-${ARCH}.run +CANN_KERNELS_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-kernels-${TARGET}_8.1.RC1_linux-${ARCH}.run +CANN_NNRT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-nnrt_8.1.RC1_linux-${ARCH}.run + add_verbose() { if docker build -h 2>&1 | grep -q "\-\-progress"; then build_args="--no-cache --progress=plain" @@ -64,6 +100,20 @@ main() { cat > Dockerfile.tmp << EOF FROM base_env +RUN set -ex && \\ + cd /root && \\ + wget --header="Referer: https://www.hiascend.com/" ${CANN_TOOLKIT_URL} -O Ascend-cann-toolkit.run --no-check-certificate && \\ + wget --header="Referer: https://www.hiascend.com/" ${CANN_KERNELS_URL} -O Ascend-cann-kernels-${TARGET}.run --no-check-certificate && \\ + wget --header="Referer: https://www.hiascend.com/" ${CANN_NNRT_URL} -O Ascend-cann-nnrt.run --no-check-certificate + +RUN set -ex && \\ + cd /root && \\ + chmod a+x *.run && \\ + bash /root/Ascend-cann-toolkit.run --install -q && \\ + bash /root/Ascend-cann-kernels-${TARGET}.run --install -q && \\ + bash Ascend-cann-nnrt.run --install -q && \\ + rm /root/*.run + COPY install_depend_pkgs.sh /workspace/ COPY .jenkins/test/config/dependent_packages.yaml /workspace/.jenkins/test/config/ ADD ./ /workspace/vllm_mindspore