diff --git a/Dockerfile b/Dockerfile index f579daff0dad98859b29cfc286eccabc88463c05..758d075cf3b64f3a8e5d861793930443442fd7cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,6 @@ FROM hub.oepkgs.net/openeuler/openeuler:22.03-lts-sp4 -ARG ARCH=aarch64 - RUN set -ex && \ echo "[OS]" > /etc/yum.repos.d/openEuler.repo && \ echo "name=OS" >> /etc/yum.repos.d/openEuler.repo && \ @@ -72,13 +70,15 @@ RUN set -ex && \ zlib-devel \ gzip \ zip \ + coreutils \ && yum clean all \ && rm -rf /var/cache/yum WORKDIR /root RUN set -ex && \ - wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py311_25.1.1-2-Linux-${ARCH}.sh && \ + ARCH=$(uname -m) && \ + wget https://repo.anaconda.com/miniconda/Miniconda3-py311_25.1.1-2-Linux-${ARCH}.sh && \ bash /root/Miniconda3-py311_25.1.1-2-Linux-${ARCH}.sh -b && \ rm /root/Miniconda3-py311_25.1.1-2-Linux-${ARCH}.sh @@ -86,8 +86,8 @@ ENV PATH="/root/miniconda3/bin:$PATH" ENV PYTHONPATH="/root/miniconda3/lib/python3.11/site-packages" RUN set -ex && \ - pip config set global.index-url 'https://pypi.tuna.tsinghua.edu.cn/simple' && \ - pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn + pip config set global.index-url 'https://mirrors.aliyun.com/pypi/simple/' && \ + pip config set global.trusted-host mirrors.aliyun.com RUN set -ex && \ echo "UserName=HwHiAiUser" >> /etc/ascend_install.info && \ @@ -101,9 +101,17 @@ RUN set -ex && \ echo "Driver_Install_Status=complete" >> /etc/ascend_install.info RUN set -ex && \ - curl -s -k "https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-toolkit_8.1.RC1_linux-${ARCH}.run" -o Ascend-cann-toolkit.run && \ - curl -s -k "https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-kernels-910b_8.1.RC1_linux-${ARCH}.run" -o Ascend-cann-kernels-910b.run && \ - curl -s -k "https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-nnrt_8.1.RC1_linux-${ARCH}.run" -o Ascend-cann-nnrt.run && \ + 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 && \ @@ -116,7 +124,7 @@ RUN set -ex && \ RUN set -ex && \ pip install --no-cache-dir \ - "cmake>=3.26" \ + cmake>=3.26 \ decorator \ ray==2.43.0 \ protobuf==3.20.0 \ @@ -127,7 +135,7 @@ RUN set -ex && \ deprecated \ packaging \ ninja \ - "setuptools-scm>=8" \ + setuptools-scm>=8 \ numpy \ numba \ build diff --git a/build_image.sh b/build_image.sh index 52a5445eaec5109910df1b502718f4ccc7e3f691..2494784fce152cb19c54b8704f8155c4c0d1e29b 100644 --- a/build_image.sh +++ b/build_image.sh @@ -18,17 +18,42 @@ set -euo pipefail readonly IMAGE_TAG="vllm_ms_$(date +%Y%m%d)" -ARCH=$([ "$(uname -m)" = "x86_64" ] && echo "x86_64" || echo "aarch64") log() { echo "========= $*" } +add_verbose() { + if docker build -h 2>&1 | grep -q "\-\-progress"; then + build_args="--no-cache --progress=plain" + else + build_args="--no-cache" + fi +} + +build_args="" + +get_run_opts() { + while getopts ":vh" opt; do + case $opt in + v) + add_verbose + ;; + h) + echo "Usage: bash build_image.sh [-v]" + echo " verbose: print docker build logs in details" + exit 0 + ;; + esac + done +} + main() { log "Starting Docker image build process" - log "Step 1: Building base environment for $ARCH" - docker image inspect base_env >/dev/null 2>&1 || docker build --build-arg TARGETARCH=$ARCH -t base_env -f Dockerfile . + log "Step 1: Building base environment" + + docker image inspect base_env >/dev/null 2>&1 || docker build -t base_env -f Dockerfile . ${build_args} log "Step 2: Building final image with install script" @@ -41,11 +66,15 @@ FROM base_env COPY install_depend_pkgs.sh /workspace/ COPY .jenkins/test/config/dependent_packages.yaml /workspace/.jenkins/test/config/ +ADD ./ /workspace/vllm_mindspore ARG MINDFORMERS_COMMIT=$mindformers_commit -RUN chmod +x /workspace/install_depend_pkgs.sh && \\ - cd /workspace && \\ - MINDFORMERS_COMMIT=\$MINDFORMERS_COMMIT ./install_depend_pkgs.sh +RUN chmod +x /workspace/vllm_mindspore/install_depend_pkgs.sh && \\ + cd /workspace/vllm_mindspore && \\ + MINDFORMERS_COMMIT=\$MINDFORMERS_COMMIT AUTO_BUILD=1 ./install_depend_pkgs.sh + +RUN cd /workspace/vllm_mindspore && \\ + pip install . ENV PYTHONPATH="/workspace/mindformers/:\$PYTHONPATH" WORKDIR /workspace @@ -53,7 +82,7 @@ WORKDIR /workspace CMD ["bash"] EOF - docker build -f Dockerfile.tmp -t "$IMAGE_TAG" . || { + docker build -f Dockerfile.tmp -t "$IMAGE_TAG" . ${build_args}|| { echo "Failed to build final image" rm -f Dockerfile.tmp exit 1 @@ -63,4 +92,6 @@ EOF log "Build completed: $IMAGE_TAG" } +get_run_opts "$@" + main "$@" diff --git a/install_depend_pkgs.sh b/install_depend_pkgs.sh index b99ae541bb31e83a2dc7d668664a504084e11536..55bf53fbb354f5c79880e18bc6c6899b14a7daaa 100644 --- a/install_depend_pkgs.sh +++ b/install_depend_pkgs.sh @@ -118,6 +118,7 @@ install_mindformers() { cd "$MF_DIR" git checkout "$commit_id" cd "$SCRIPT_DIR" + pip install $PIP_TRUSTED_HOSTS $PIP_INDEX -r mindformers/requirements.txt log "Using mindformers commit: $commit_id" } @@ -183,7 +184,7 @@ main() { log "Starting dependency installation" local vllm_url=$(get_package_url "vllm" "any") - local mindspore_url=$(get_package_url "mindspore" "unified/$ARCH") + local mindspore_url=$(get_package_url "mindspore" "unified/${ARCH}") local msadapter_url=$(get_package_url "msadapter" "any") local mindspore_gs_url=$(get_package_url "mindspore_gs" "any") @@ -208,7 +209,5 @@ main() { log "" log "When using MindFormers backend, please configure environment variables manually:" echo " export PYTHONPATH=\"$MF_DIR/:\$PYTHONPATH\"" - echo " export VLLM_MS_MODEL_BACKEND=MindFormers" } - main "$@"