ARG BASE_IMAGE_VERSION=9.0.1
ARG NPU_TYPE=910b
ARG OS=ubuntu22.04
ARG PYTHON_VERSION=3.12
FROM swr.cn-south-1.myhuaweicloud.com/ascendhub/cann:${BASE_IMAGE_VERSION}-${NPU_TYPE}-${OS}-py${PYTHON_VERSION}
LABEL maintainer="mindspeed-dev"
LABEL description="MindSpeed development container based on CANN / Ubuntu / Python 3.12"
ARG TORCH_VERSION=2.9.0
ARG TORCH_NPU_VERSION=2.9.0
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
gcc \
g++ \
ninja-build \
ccache \
curl \
git \
jq \
libnuma-dev \
unzip \
vim \
wget \
clang-format-14 \
&& rm -rf /var/lib/apt/lists/*
RUN ARCH=$(uname -m) && \
PIP_EXTRA="--extra-index-url https://mirrors.aliyun.com/pypi/simple/"; \
if [ "$ARCH" = "x86_64" ]; then \
PIP_EXTRA="--extra-index-url https://download.pytorch.org/whl/cpu/"; \
fi && \
pip3 config set global.extra-index-url "$(echo ${PIP_EXTRA} | sed 's/--extra-index-url //')" && \
pip3 install --no-cache-dir --upgrade pip packaging setuptools==80.10.2 && \
pip3 install --no-cache-dir \
ruff \
pylint \
bandit \
codespell \
pre-commit \
ipython \
ipdb \
&& pip3 cache purge
RUN ARCH=$(uname -m) && \
GITLEAKS_VER="8.20.0" && \
if [ "$ARCH" = "x86_64" ]; then \
URL="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VER}/gitleaks_${GITLEAKS_VER}_linux_x64.tar.gz"; \
elif [ "$ARCH" = "aarch64" ]; then \
URL="https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VER}/gitleaks_${GITLEAKS_VER}_linux_arm64.tar.gz"; \
else \
echo "ERROR: Unsupported architecture: ${ARCH}"; exit 1; \
fi && \
wget -q "$URL" -O /tmp/gitleaks.tar.gz && \
tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks && \
rm -f /tmp/gitleaks.tar.gz && \
chmod +x /usr/local/bin/gitleaks
RUN if ! python3 -c "import torch" 2>/dev/null; then \
ARCH=$(uname -m) && \
PIP_EXTRA="--extra-index-url https://mirrors.aliyun.com/pypi/simple/"; \
if [ "$ARCH" = "x86_64" ]; then \
PIP_EXTRA="--extra-index-url https://download.pytorch.org/whl/cpu/"; \
fi && \
pip3 install ${PIP_EXTRA} torch==${TORCH_VERSION} torch_npu==${TORCH_NPU_VERSION} && \
pip3 cache purge; \
fi
RUN mkdir -p /ccache && ccache -M 5G
ENV CCACHE_DIR=/ccache
ENV PATH="/usr/lib/ccache:${PATH}"
WORKDIR /workspace
CMD ["/bin/bash"]