diff --git a/.github/actions/init-env/action.yml b/.github/actions/init-env/action.yml new file mode 100644 index 0000000..f8e69eb --- /dev/null +++ b/.github/actions/init-env/action.yml @@ -0,0 +1,11 @@ +name: "Init environment" +description: "Initialize working environment" +runs: + using: "composite" + steps: + - name: Prepare CANN installers + shell: bash + run: | + set -x + cp -nv /data/cann/*.run ./cann/ + ls -alh ./cann/ diff --git a/.github/workflows/_docker-build.yml b/.github/workflows/_docker-build.yml index 9f89e6b..4a3d6e6 100644 --- a/.github/workflows/_docker-build.yml +++ b/.github/workflows/_docker-build.yml @@ -34,7 +34,7 @@ on: ascendhub-registry: description: "Server address of AscendHub registry" required: false - type: string + type: string default: "swr.cn-east-3.myhuaweicloud.com" secrets: DOCKERHUB_OWNER: @@ -80,7 +80,7 @@ permissions: jobs: prepare: name: prepare - runs-on: ubuntu-latest + runs-on: linux-x64-azure outputs: targets: ${{ steps.list-target.outputs.targets }} steps: @@ -98,7 +98,7 @@ jobs: docker: name: build ${{ matrix.target }} - runs-on: ubuntu-24.04-arm # TODO: Use ubuntu-latest + runs-on: linux-x64-azure needs: - prepare strategy: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 17b1a24..1f3f2c1 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -55,7 +55,7 @@ permissions: jobs: prepare: name: prepare - runs-on: ubuntu-latest + runs-on: linux-x64-azure outputs: pr-labels: ${{ steps.list-labels.outputs.labels }} targets: ${{ steps.list-targets.outputs.targets }} @@ -87,7 +87,7 @@ jobs: !cancelled() && contains(needs.prepare.outputs.targets, 'python') && ( - (github.event_name != 'pull_request' && success()) || + (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && contains(needs.prepare.outputs.pr-labels, 'python')) ) uses: ./.github/workflows/_docker-build.yml @@ -108,14 +108,16 @@ jobs: if: | !cancelled() && contains(needs.prepare.outputs.targets, 'cann') && + (needs.python.result == 'success' || needs.python.result == 'skipped') && ( - (github.event_name != 'pull_request' && success()) || + (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && contains(needs.prepare.outputs.pr-labels, 'cann')) ) uses: ./.github/workflows/_docker-build.yml with: target: 'cann' push: ${{ github.event_name == 'release' }} + clean-up: false secrets: inherit pytorch: @@ -126,14 +128,16 @@ jobs: if: | !cancelled() && contains(needs.prepare.outputs.targets, 'pytorch') && + (needs.cann.result == 'success' || needs.cann.result == 'skipped') && ( - (github.event_name != 'pull_request' && success()) || + (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && contains(needs.prepare.outputs.pr-labels, 'pytorch')) ) uses: ./.github/workflows/_docker-build.yml with: target: 'pytorch' push: ${{ github.event_name == 'release' }} + clean-up: false secrets: inherit mindspore: @@ -144,12 +148,14 @@ jobs: if: | !cancelled() && contains(needs.prepare.outputs.targets, 'mindspore') && + (needs.cann.result == 'success' || needs.cann.result == 'skipped') && ( - (github.event_name != 'pull_request' && success()) || + (github.event_name != 'pull_request') || (github.event_name == 'pull_request' && contains(needs.prepare.outputs.pr-labels, 'mindspore')) ) uses: ./.github/workflows/_docker-build.yml with: target: 'mindspore' push: ${{ github.event_name == 'release' }} + clean-up: false secrets: inherit diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index ba00065..ddacf1b 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -5,7 +5,7 @@ on: pull_request_target jobs: label: name: Label - runs-on: ubuntu-latest + runs-on: linux-x64-azure permissions: contents: read pull-requests: write diff --git a/.gitignore b/.gitignore index 293b497..b6c98d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea .secrets +**/*.run diff --git a/arg.json b/arg.json index 5ecc9d5..b06f60e 100644 --- a/arg.json +++ b/arg.json @@ -1,15 +1,5 @@ { "registry": [ - { - "name": "dockerhub", - "url": "docker.io", - "owner": "ascendai" - }, - { - "name": "quay", - "url": "quay.io", - "owner": "ascend" - }, { "name": "huawei-swr", "url": "swr.cn-southwest-2.myhuaweicloud.com", @@ -19,411 +9,52 @@ "name": "ascendhub", "url": "swr.cn-east-3.myhuaweicloud.com", "owner": "ascendhub-test" - } - ], - "cann": [ - { - "cann_version": "7.0.1", - "cann_chip": "910b", - "os_name": "ubuntu", - "os_version": "22.04", - "py_version": "3.8", - "tags": { - "common": [ - "7.0.1-910b-ubuntu22.04-py3.8", - "7.0.1", - "ubuntu-python3.8-cann7.0.1" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "7.0.1", - "cann_chip": "910b", - "os_name": "openeuler", - "os_version": "22.03", - "py_version": "3.8", - "tags": { - "common": [ - "7.0.1-910b-openeuler22.03-py3.8", - "openeuler-python3.8-cann7.0.1" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "8.0.RC1", - "cann_chip": "910b", - "os_name": "ubuntu", - "os_version": "22.04", - "py_version": "3.8", - "tags": { - "common": [ - "8.0.rc1-910b-ubuntu22.04-py3.8", - "8.0.rc1", - "ubuntu-python3.8-cann8.0.rc1" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "8.0.RC1", - "cann_chip": "910b", - "os_name": "openeuler", - "os_version": "22.03", - "py_version": "3.8", - "tags": { - "common": [ - "8.0.rc1-910b-openeuler22.03-py3.8", - "openeuler-python3.8-cann8.0.rc1" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "8.0.RC2", - "cann_chip": "910b", - "os_name": "openeuler", - "os_version": "22.03", - "py_version": "3.8", - "tags": { - "common": [ - "8.0.rc2-910b-openeuler22.03-py3.8", - "openeuler-python3.8-cann8.0.rc2" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "8.0.RC2", - "cann_chip": "910b", - "os_name": "ubuntu", - "os_version": "22.04", - "py_version": "3.9", - "tags": { - "common": [ - "8.0.rc2-910b-ubuntu22.04-py3.9", - "ubuntu-python3.9-cann8.0.rc2" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "8.0.RC2", - "cann_chip": "910b", - "os_name": "openeuler", - "os_version": "22.03", - "py_version": "3.9", - "tags": { - "common": [ - "8.0.rc2-910b-openeuler22.03-py3.9", - "openeuler-python3.9-cann8.0.rc2" - ], - "ascendhub": [ - ] - } - }, - { - "cann_version": "8.0.RC2", - "cann_chip": "910b", - "os_name": "openeuler", - "os_version": "22.03", - "py_version": "3.10", - "tags": { - "common": [ - "8.0.rc2-910b-openeuler22.03-py3.10", - "openeuler-python3.10-cann8.0.rc2" - ], - "ascendhub": [ - ] - } }, { - "cann_version": "8.0.RC2", - "cann_chip": "910b", - "os_name": "ubuntu", - "os_version": "22.04", - "py_version": "3.10", - "tags": { - "common": [ - "8.0.rc2-910b-ubuntu22.04-py3.10", - "8.0.rc2", - "ubuntu-python3.10-cann8.0.rc2" - ], - "ascendhub": [ - ] - } + "name": "dockerhub", + "url": "docker.io", + "owner": "ascendai" }, { - "cann_version": "8.0.RC3", - "cann_chip": "910b", - "os_name": "ubuntu", - "os_version": "22.04", - "py_version": "3.10", - "tags": { - "common": [ - "8.0.rc3-910b-ubuntu22.04-py3.10", - "ubuntu-python3.10-cann8.0.rc3" - ], - "ascendhub": [ - ] - } - }, + "name": "quay", + "url": "quay.io", + "owner": "ascend" + } + ], + "cann": [ { - "cann_version": "8.0.RC3", + "cann_version": "8.1.RC1.alpha001", "cann_chip": "910b", "os_name": "openeuler", "os_version": "22.03", "py_version": "3.10", + "nnal_version": "8.0.0", "tags": { "common": [ - "8.0.rc3-910b-openeuler22.03-py3.10", - "openeuler-python3.10-cann8.0.rc3" + "8.1.RC1.alpha001-910b-openeuler22.03-py3.10", + "openeuler-python3.10-cann8.1.RC1.alpha001" ], "ascendhub": [ + "8.1.RC1.alpha001-910b-openeuler22.03-py3.10" ] } }, { - "cann_version": "8.0.0", + "cann_version": "8.1.RC1.alpha001", "cann_chip": "910b", "os_name": "ubuntu", "os_version": "22.04", "py_version": "3.10", + "nnal_version": "8.0.0", "tags": { "common": [ - "8.0.0-910b-ubuntu22.04-py3.10", - "8.0.0", + "8.1.RC1.alpha001-910b-ubuntu22.04-py3.10", + "8.1.RC1.alpha001", "latest", - "ubuntu-python3.10-cann8.0.0" - ], - "ascendhub": [ - "8.0.0-910b-ubuntu22.04-py3.10" - ] - } - }, - { - "cann_version": "8.0.0", - "cann_chip": "910b", - "os_name": "openeuler", - "os_version": "22.03", - "py_version": "3.10", - "tags": { - "common": [ - "8.0.0-910b-openeuler22.03-py3.10", - "openeuler-python3.10-cann8.0.0" - ], - "ascendhub": [ - "8.0.0-910b-openeuler22.03-py3.10" - ] - } - } - ], - "python": [ - { - "py_version": "3.8", - "os_name": "ubuntu", - "os_version": "22.04", - "tags": { - "common": [ - "3.8-ubuntu22.04", - "3.8" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.9", - "os_name": "ubuntu", - "os_version": "22.04", - "tags": { - "common": [ - "3.9-ubuntu22.04", - "3.9" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.10", - "os_name": "ubuntu", - "os_version": "22.04", - "tags": { - "common": [ - "3.10-ubuntu22.04", - "3.10" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.11", - "os_name": "ubuntu", - "os_version": "22.04", - "tags": { - "common": [ - "3.11-ubuntu22.04", - "3.11" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.12", - "os_name": "ubuntu", - "os_version": "22.04", - "tags": { - "common": [ - "3.12-ubuntu22.04", - "3.12" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.13", - "os_name": "ubuntu", - "os_version": "22.04", - "tags": { - "common": [ - "3.13-ubuntu22.04", - "3.13" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.8", - "os_name": "openeuler", - "os_version": "22.03", - "tags": { - "common": [ - "3.8-openeuler22.03" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.9", - "os_name": "openeuler", - "os_version": "22.03", - "tags": { - "common": [ - "3.9-openeuler22.03" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.10", - "os_name": "openeuler", - "os_version": "22.03", - "tags": { - "common": [ - "3.10-openeuler22.03" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.11", - "os_name": "openeuler", - "os_version": "22.03", - "tags": { - "common": [ - "3.11-openeuler22.03" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.12", - "os_name": "openeuler", - "os_version": "22.03", - "tags": { - "common": [ - "3.12-openeuler22.03" - ], - "ascendhub": [ - ] - } - }, - { - "py_version": "3.13", - "os_name": "openeuler", - "os_version": "22.03", - "tags": { - "common": [ - "3.13-openeuler22.03" - ], - "ascendhub": [ - ] - } - } - ], - "pytorch": [ - { - "pytorch_version": "2.1.0", - "cann_tag": "8.0.rc1-910b-ubuntu22.04-py3.8", - "tags": { - "common": [ - "2.1.0", - "ubuntu-python3.8-cann8.0.rc1-pytorch2.1.0" - ], - "ascendhub": [ - ] - } - }, - { - "pytorch_version": "2.2.0", - "cann_tag": "8.0.rc1-910b-ubuntu22.04-py3.8", - "tags": { - "common": [ - "2.2.0", - "ubuntu-python3.8-cann8.0.rc1-pytorch2.2.0" - ], - "ascendhub": [ - ] - } - } - ], - "mindspore": [ - { - "mindspore_version": "2.4.0", - "cann_tag": "8.0.rc3-910b-ubuntu22.04-py3.10", - "tags": { - "common": [ - "2.4.0", - "ubuntu-python3.10-cann8.0.rc3-mindspore2.4.0" - ], - "ascendhub": [ - ] - } - }, - { - "mindspore_version": "2.4.0", - "cann_tag": "8.0.rc3-910b-openeuler22.03-py3.10", - "tags": { - "common": [ - "openeuler-python3.10-cann8.0.rc3-mindspore2.4.0" + "ubuntu-python3.10-cann8.1.RC1.alpha001" ], "ascendhub": [ + "8.1.RC1.alpha001-910b-ubuntu22.04-py3.10" ] } } diff --git a/cann/cann.sh b/cann/cann.sh index 62eca7d..0d4bc48 100755 --- a/cann/cann.sh +++ b/cann/cann.sh @@ -40,8 +40,12 @@ _retry() { } _download_file() { - _info "Downloading file from $1" - _retry curl -fsSL -o "$2" "$1" + if [ -f "$2" ]; then + _info "$2 already exists" + else + _info "Downloading file from $1" + _retry curl -fsSL -o "$2" "$1" + fi } download_cann() { @@ -50,8 +54,10 @@ download_cann() { version_dict["8.0.RC2.alpha002"]="V100R001C18SPC805" version_dict["8.0.RC2.alpha003"]="V100R001C18SPC703" version_dict["8.0.RC3.alpha002"]="V100R001C19SPC702" + version_dict["8.1.RC1.alpha001"]="V100R001C21B800TP034" local url="https://ascend-repo.obs.cn-east-2.myhuaweicloud.com" + if [[ ${CANN_VERSION} == *alpha* ]]; then local version=${version_dict[${CANN_VERSION}]} if [[ ${version} ]]; then @@ -63,21 +69,19 @@ download_cann() { local url_prefix="${url}/CANN/CANN%20${CANN_VERSION}" fi + local nnal_url_prefix="${url}/CANN/CANN%20${NNAL_VERSION}" + # Download cann-toolkit - if [ ! -f "${TOOLKIT_PATH}" ]; then - local toolkit_url="${url_prefix}/${TOOLKIT_FILE}" - _download_file "${toolkit_url}" "${TOOLKIT_PATH}" - fi + local toolkit_url="${url_prefix}/${TOOLKIT_FILE}" + _download_file "${toolkit_url}" "${TOOLKIT_PATH}" # Download cann-kernels - if [ ! -f "${KERNELS_PATH}" ]; then - local kernels_url="${url_prefix}/${KERNELS_FILE}" - _download_file "${kernels_url}" "${KERNELS_PATH}" - fi + local kernels_url="${url_prefix}/${KERNELS_FILE}" + _download_file "${kernels_url}" "${KERNELS_PATH}" - # Download cann-kernels - if [[ ${CANN_VERSION} == "8.0.0" ]]; then - local nnal_url="${url_prefix}/${NNAL_FILE}" + # Download cann-nnals + if [[ ${CANN_VERSION} == "8.1.RC1.alpha001" ]]; then + local nnal_url="${nnal_url_prefix}/${NNAL_FILE}" _download_file "${nnal_url}" "${NNAL_PATH}" fi @@ -106,8 +110,9 @@ install_cann() { fi # Install dependencies - pip install --no-cache-dir --upgrade pip - pip install --no-cache-dir \ + pip install \ + --no-cache-dir \ + --index-url https://repo.huaweicloud.com/repository/pypi/simple \ attrs cython numpy==1.24.0 decorator sympy cffi pyyaml pathlib2 \ psutil protobuf==3.20 scipy requests absl-py @@ -115,7 +120,6 @@ install_cann() { _info "Installing ${TOOLKIT_FILE}" chmod +x "${TOOLKIT_PATH}" bash "${TOOLKIT_PATH}" --quiet --install --install-for-all --install-path="${CANN_HOME}" - rm -f "${TOOLKIT_PATH}" # Set environment variables set_env @@ -124,14 +128,12 @@ install_cann() { _info "Installing ${KERNELS_FILE}" chmod +x "${KERNELS_PATH}" bash "${KERNELS_PATH}" --quiet --install --install-for-all --install-path="${CANN_HOME}" - rm -f "${KERNELS_PATH}" # Install CANN NNAL - if [[ ${CANN_VERSION} == "8.0.0" ]]; then + if [[ ${CANN_VERSION} == "8.1.RC1.alpha001" ]]; then _info "Installing ${NNAL_PATH}" chmod +x "${NNAL_PATH}" bash "${NNAL_PATH}" --quiet --install --install-for-all --install-path="${CANN_HOME}" - rm -f "${NNAL_PATH}" # Set environment variables local cann_nnal_env_file="${CANN_HOME}/nnal/atb/set_env.sh" @@ -152,7 +154,7 @@ CANN_CHIP=${CANN_CHIP:="910b"} CANN_VERSION=${CANN_VERSION:="8.0.0"} # NOTE: kernels are arch-specific after 8.0.RC3.alpha002 -if [[ ${CANN_VERSION} == "8.0.RC3" || ${CANN_VERSION} == "8.0.0" ]]; then +if [[ ${CANN_VERSION} == "8.1.RC1.alpha001" || ${CANN_VERSION} == "8.0.0" ]]; then KERNELS_ARCH="linux-${ARCH}" else KERNELS_ARCH="linux" @@ -160,7 +162,7 @@ fi TOOLKIT_FILE="Ascend-cann-toolkit_${CANN_VERSION}_linux-${ARCH}.run" KERNELS_FILE="Ascend-cann-kernels-${CANN_CHIP}_${CANN_VERSION}_${KERNELS_ARCH}.run" -NNAL_FILE="Ascend-cann-nnal_${CANN_VERSION}_linux-${ARCH}.run" +NNAL_FILE="Ascend-cann-nnal_${NNAL_VERSION}_linux-${ARCH}.run" TOOLKIT_PATH="/tmp/${TOOLKIT_FILE}" KERNELS_PATH="/tmp/${KERNELS_FILE}" NNAL_PATH="/tmp/${NNAL_FILE}" diff --git a/cann/openeuler.Dockerfile b/cann/openeuler.Dockerfile index 339aad7..30f2211 100644 --- a/cann/openeuler.Dockerfile +++ b/cann/openeuler.Dockerfile @@ -9,6 +9,10 @@ FROM ascendai/python:${PY_VERSION}-openeuler${BASE_VERSION} AS cann-installer ARG PLATFORM=${TARGETPLATFORM} ARG CANN_CHIP=910b ARG CANN_VERSION=8.0.0 +ARG NNAL_VERSION=${CANN_VERSION} + +# Change the default shell +SHELL [ "/bin/bash", "-c" ] # Install dependencies RUN yum update -y && \ @@ -33,7 +37,10 @@ RUN yum update -y && \ && rm -rf /var/cache/yum \ && rm -rf /tmp/* -COPY ./cann.sh /tmp/cann.sh +# Note: If you put your installers here, they won't be downloaded again. +COPY ./cann.sh /tmp/ +COPY ./*.run /tmp/ +# RUN cp -nv *.run /tmp/ || true RUN bash /tmp/cann.sh --download RUN bash /tmp/cann.sh --install @@ -43,9 +50,56 @@ FROM openeuler/openeuler:${BASE_VERSION} AS official # Arguments ARG PY_VERSION -# Environment variables +# Set Python Environment variables ENV PATH=/usr/local/python${PY_VERSION}/bin:${PATH} -ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:${LD_LIBRARY_PATH} + +# Toolkit Environment variables +ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest +ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common/:/usr/local/Ascend/driver/lib64/driver/:$LD_LIBRARY_PATH +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/lib64/plugin/opskernel:${ASCEND_TOOLKIT_HOME}/lib64/plugin/nnengine:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe/op_tiling:$LD_LIBRARY_PATH +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/tools/aml/lib64:${ASCEND_TOOLKIT_HOME}/tools/aml/lib64/plugin:$LD_LIBRARY_PATH +ENV PYTHONPATH=${ASCEND_TOOLKIT_HOME}/python/site-packages:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe:$PYTHONPATH +ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${ASCEND_TOOLKIT_HOME}/compiler/ccec_compiler/bin:${ASCEND_TOOLKIT_HOME}/tools/ccec_compiler/bin:$PATH +ENV ASCEND_AICPU_PATH=${ASCEND_TOOLKIT_HOME} +ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp +ENV TOOLCHAIN_HOME=${ASCEND_TOOLKIT_HOME}/toolkit +ENV ASCEND_HOME_PATH=${ASCEND_TOOLKIT_HOME} + +# Nnal Environment variables +ENV ATB_HOME_PATH=/usr/local/Ascend/nnal/atb/latest/atb/cxx_abi_1 +ENV LD_LIBRARY_PATH=${ATB_HOME_PATH}/lib:${ATB_HOME_PATH}/examples:${ATB_HOME_PATH}/tests/atbopstest:${LD_LIBRARY_PATH} +ENV PATH=${ATB_HOME_PATH}/bin:$PATH + +# Acceleration Library Environment variables +ENV ATB_STREAM_SYNC_EVERY_KERNEL_ENABLE=0 +ENV ATB_STREAM_SYNC_EVERY_RUNNER_ENABLE=0 +ENV ATB_STREAM_SYNC_EVERY_OPERATION_ENABLE=0 +ENV ATB_OPSRUNNER_SETUP_CACHE_ENABLE=1 +ENV ATB_OPSRUNNER_KERNEL_CACHE_TYPE=3 +ENV ATB_OPSRUNNER_KERNEL_CACHE_LOCAL_COUNT=1 +ENV ATB_OPSRUNNER_KERNEL_CACHE_GLOABL_COUNT=5 +ENV ATB_OPSRUNNER_KERNEL_CACHE_TILING_SIZE=10240 +ENV ATB_WORKSPACE_MEM_ALLOC_ALG_TYPE=1 +ENV ATB_WORKSPACE_MEM_ALLOC_GLOBAL=0 +ENV ATB_COMPARE_TILING_EVERY_KERNEL=0 +ENV ATB_HOST_TILING_BUFFER_BLOCK_NUM=128 +ENV ATB_DEVICE_TILING_BUFFER_BLOCK_NUM=32 +ENV ATB_SHARE_MEMORY_NAME_SUFFIX="" +ENV ATB_LAUNCH_KERNEL_WITH_TILING=1 +ENV ATB_MATMUL_SHUFFLE_K_ENABLE=1 +ENV ATB_RUNNER_POOL_SIZE=64 + +# Operator Library Environment variables +ENV ASDOPS_HOME_PATH=${ATB_HOME_PATH} +ENV ASDOPS_MATMUL_PP_FLAG=1 +ENV ASDOPS_LOG_LEVEL=ERROR +ENV ASDOPS_LOG_TO_STDOUT=0 +ENV ASDOPS_LOG_TO_FILE=1 +ENV ASDOPS_LOG_TO_FILE_FLUSH=0 +ENV ASDOPS_LOG_TO_BOOST_TYPE=atb +ENV ASDOPS_LOG_PATH=/root +ENV ASDOPS_TILING_PARSE_CACHE_DISABLE=0 +ENV LCCL_DETERMINISTIC=0 # Change the default shell SHELL [ "/bin/bash", "-c" ] @@ -64,31 +118,4 @@ RUN yum update -y && \ # Copy files COPY --from=cann-installer /usr/local/python${PY_VERSION} /usr/local/python${PY_VERSION} COPY --from=cann-installer /usr/local/Ascend /usr/local/Ascend -COPY --from=cann-installer /etc/Ascend /etc/Ascend - -# Set environment variables -RUN \ - # Set environment variables for Python \ - PY_PATH="PATH=/usr/local/python${PY_VERSION}/bin:\${PATH}" && \ - echo "export ${PY_PATH}" >> /etc/profile && \ - echo "export ${PY_PATH}" >> ~/.bashrc && \ - # Set environment variables for CANN \ - CANN_TOOLKIT_ENV_FILE="/usr/local/Ascend/ascend-toolkit/set_env.sh" && \ - DRIVER_LIBRARY_PATH="LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:\${LD_LIBRARY_PATH}" && \ - echo "export ${DRIVER_LIBRARY_PATH}" >> /etc/profile && \ - echo "export ${DRIVER_LIBRARY_PATH}" >> ~/.bashrc && \ - echo "source ${CANN_TOOLKIT_ENV_FILE}" >> /etc/profile && \ - echo "source ${CANN_TOOLKIT_ENV_FILE}" >> ~/.bashrc && \ - echo "source ${CANN_TOOLKIT_ENV_FILE}" >> ~/.bashrc && \ - CANN_NNAL_ENV_FILE="/usr/local/Ascend/nnal/atb/set_env.sh" && \ - if [ -f "${CANN_NNAL_ENV_FILE}" ]; then \ - echo "source ${CANN_NNAL_ENV_FILE}" >> /etc/profile && \ - echo "source ${CANN_NNAL_ENV_FILE}" >> ~/.bashrc; \ - fi - -ENTRYPOINT ["/bin/bash", "-c", "\ - source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ - if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then \ - source /usr/local/Ascend/nnal/atb/set_env.sh; \ - fi && \ - exec \"$@\"", "--"] +COPY --from=cann-installer /etc/Ascend /etc/Ascend \ No newline at end of file diff --git a/cann/ubuntu.Dockerfile b/cann/ubuntu.Dockerfile index cefd1c4..7a783e1 100644 --- a/cann/ubuntu.Dockerfile +++ b/cann/ubuntu.Dockerfile @@ -9,6 +9,10 @@ FROM ascendai/python:${PY_VERSION}-ubuntu${BASE_VERSION} AS cann-installer ARG PLATFORM=${TARGETPLATFORM} ARG CANN_CHIP=910b ARG CANN_VERSION=8.0.0 +ARG NNAL_VERSION=${CANN_VERSION} + +# Change the default shell +SHELL [ "/bin/bash", "-c" ] # Install dependencies RUN apt-get update \ @@ -41,7 +45,10 @@ RUN apt-get update \ && rm -rf /var/tmp/* \ && rm -rf /tmp/* -COPY ./cann.sh /tmp/cann.sh +# Note: If you put your installers here, they won't be downloaded again. +COPY ./cann.sh /tmp/ +COPY ./*.run /tmp/ +# RUN cp -nv *.run /tmp/ || true RUN bash /tmp/cann.sh --download RUN bash /tmp/cann.sh --install @@ -51,9 +58,56 @@ FROM ubuntu:${BASE_VERSION} AS official # Arguments ARG PY_VERSION -# Environment variables +# Set Python Environment variables ENV PATH=/usr/local/python${PY_VERSION}/bin:${PATH} -ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:${LD_LIBRARY_PATH} + +# Toolkit Environment variables +ENV ASCEND_TOOLKIT_HOME=/usr/local/Ascend/ascend-toolkit/latest +ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common/:/usr/local/Ascend/driver/lib64/driver/:$LD_LIBRARY_PATH +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/lib64/plugin/opskernel:${ASCEND_TOOLKIT_HOME}/lib64/plugin/nnengine:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe/op_tiling:$LD_LIBRARY_PATH +ENV LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/tools/aml/lib64:${ASCEND_TOOLKIT_HOME}/tools/aml/lib64/plugin:$LD_LIBRARY_PATH +ENV PYTHONPATH=${ASCEND_TOOLKIT_HOME}/python/site-packages:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe:$PYTHONPATH +ENV PATH=${ASCEND_TOOLKIT_HOME}/bin:${ASCEND_TOOLKIT_HOME}/compiler/ccec_compiler/bin:${ASCEND_TOOLKIT_HOME}/tools/ccec_compiler/bin:$PATH +ENV ASCEND_AICPU_PATH=${ASCEND_TOOLKIT_HOME} +ENV ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp +ENV TOOLCHAIN_HOME=${ASCEND_TOOLKIT_HOME}/toolkit +ENV ASCEND_HOME_PATH=${ASCEND_TOOLKIT_HOME} + +# Nnal Environment variables +ENV ATB_HOME_PATH=/usr/local/Ascend/nnal/atb/latest/atb/cxx_abi_1 +ENV LD_LIBRARY_PATH=${ATB_HOME_PATH}/lib:${ATB_HOME_PATH}/examples:${ATB_HOME_PATH}/tests/atbopstest:${LD_LIBRARY_PATH} +ENV PATH=${ATB_HOME_PATH}/bin:$PATH + +# Acceleration Library Environment variables +ENV ATB_STREAM_SYNC_EVERY_KERNEL_ENABLE=0 +ENV ATB_STREAM_SYNC_EVERY_RUNNER_ENABLE=0 +ENV ATB_STREAM_SYNC_EVERY_OPERATION_ENABLE=0 +ENV ATB_OPSRUNNER_SETUP_CACHE_ENABLE=1 +ENV ATB_OPSRUNNER_KERNEL_CACHE_TYPE=3 +ENV ATB_OPSRUNNER_KERNEL_CACHE_LOCAL_COUNT=1 +ENV ATB_OPSRUNNER_KERNEL_CACHE_GLOABL_COUNT=5 +ENV ATB_OPSRUNNER_KERNEL_CACHE_TILING_SIZE=10240 +ENV ATB_WORKSPACE_MEM_ALLOC_ALG_TYPE=1 +ENV ATB_WORKSPACE_MEM_ALLOC_GLOBAL=0 +ENV ATB_COMPARE_TILING_EVERY_KERNEL=0 +ENV ATB_HOST_TILING_BUFFER_BLOCK_NUM=128 +ENV ATB_DEVICE_TILING_BUFFER_BLOCK_NUM=32 +ENV ATB_SHARE_MEMORY_NAME_SUFFIX="" +ENV ATB_LAUNCH_KERNEL_WITH_TILING=1 +ENV ATB_MATMUL_SHUFFLE_K_ENABLE=1 +ENV ATB_RUNNER_POOL_SIZE=64 + +# Operator Library Environment variables +ENV ASDOPS_HOME_PATH=${ATB_HOME_PATH} +ENV ASDOPS_MATMUL_PP_FLAG=1 +ENV ASDOPS_LOG_LEVEL=ERROR +ENV ASDOPS_LOG_TO_STDOUT=0 +ENV ASDOPS_LOG_TO_FILE=1 +ENV ASDOPS_LOG_TO_FILE_FLUSH=0 +ENV ASDOPS_LOG_TO_BOOST_TYPE=atb +ENV ASDOPS_LOG_PATH=/root +ENV ASDOPS_TILING_PARSE_CACHE_DISABLE=0 +ENV LCCL_DETERMINISTIC=0 # Change the default shell SHELL [ "/bin/bash", "-c" ] @@ -75,29 +129,3 @@ RUN apt-get update \ COPY --from=cann-installer /usr/local/python${PY_VERSION} /usr/local/python${PY_VERSION} COPY --from=cann-installer /usr/local/Ascend /usr/local/Ascend COPY --from=cann-installer /etc/Ascend /etc/Ascend - -# Set environment variables -RUN \ - # Set environment variables for Python \ - PY_PATH="PATH=/usr/local/python${PY_VERSION}/bin:\${PATH}" && \ - echo "export ${PY_PATH}" >> /etc/profile && \ - echo "export ${PY_PATH}" >> ~/.bashrc && \ - # Set environment variables for CANN \ - CANN_TOOLKIT_ENV_FILE="/usr/local/Ascend/ascend-toolkit/set_env.sh" && \ - DRIVER_LIBRARY_PATH="LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:\${LD_LIBRARY_PATH}" && \ - echo "export ${DRIVER_LIBRARY_PATH}" >> /etc/profile && \ - echo "export ${DRIVER_LIBRARY_PATH}" >> ~/.bashrc && \ - echo "source ${CANN_TOOLKIT_ENV_FILE}" >> /etc/profile && \ - echo "source ${CANN_TOOLKIT_ENV_FILE}" >> ~/.bashrc && \ - CANN_NNAL_ENV_FILE="/usr/local/Ascend/nnal/atb/set_env.sh" && \ - if [ -f "${CANN_NNAL_ENV_FILE}" ]; then \ - echo "source ${CANN_NNAL_ENV_FILE}" >> /etc/profile && \ - echo "source ${CANN_NNAL_ENV_FILE}" >> ~/.bashrc; \ - fi - -ENTRYPOINT ["/bin/bash", "-c", "\ - source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ - if [ -f /usr/local/Ascend/nnal/atb/set_env.sh ]; then \ - source /usr/local/Ascend/nnal/atb/set_env.sh; \ - fi && \ - exec \"$@\"", "--"] diff --git a/docker-bake.hcl b/docker-bake.hcl index f9f9325..213c641 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -58,6 +58,7 @@ target "cann" { PY_VERSION = "${item.py_version}" CANN_CHIP = "${item.cann_chip}" CANN_VERSION = "${item.cann_version}" + NNAL_VERSION = "${item.nnal_version}" } tags = generate_tags("cann", "${item.tags}") }