diff --git a/cann/.dockerignore b/cann/.dockerignore index f0f644ee..30ed4101 100644 --- a/cann/.dockerignore +++ b/cann/.dockerignore @@ -1,2 +1,5 @@ LICENSE README.md +Dockerfile.ubuntu +Dockerfile.openeuler +scripts/docker-entrypoint.sh diff --git a/cann/scripts/python.sh b/cann/scripts/python.sh index 22208557..614a8ce6 100755 --- a/cann/scripts/python.sh +++ b/cann/scripts/python.sh @@ -9,18 +9,18 @@ PY_MAJOR_VERSION=$(echo $PY_VERSION | cut -d'.' -f1) PY_LATEST_VERSION=$(curl -s https://www.python.org/ftp/python/ | grep -oE "${PY_VERSION}\.[0-9]+" | sort -V | tail -n 1) if [ -z "${PY_LATEST_VERSION}" ]; then echo "[WARNING] Could not find the latest version for Python ${PY_VERSION}" - PY_LATEST_VERSION="${PY_VERSION}.0" + exit 1 +else + echo "Latest Python version found: ${PY_LATEST_VERSION}" fi -echo "Latest Python version found: ${PY_LATEST_VERSION}" - PY_HOME="/usr/local/python${PY_VERSION}" PY_INSTALLER_TGZ="Python-${PY_LATEST_VERSION}.tgz" PY_INSTALLER_DIR="Python-${PY_LATEST_VERSION}" PY_INSTALLER_URL="https://repo.huaweicloud.com/python/${PY_LATEST_VERSION}/${PY_INSTALLER_TGZ}" download_python() { - # download python + # Download python echo "Downloading ${PY_INSTALLER_TGZ} from ${PY_INSTALLER_URL}" curl -fsSL -o "/tmp/${PY_INSTALLER_TGZ}" "${PY_INSTALLER_URL}" if [ $? -ne 0 ]; then @@ -30,13 +30,13 @@ download_python() { } install_python() { - # Download installer + # Download python if [ ! -f "/tmp/${PY_INSTALLER_TGZ}" ]; then echo "[WARNING] Installer do not exist, re-download it." download_python fi - # install python + # Install python echo "Installing ${PY_INSTALLER_DIR}" tar -xf /tmp/${PY_INSTALLER_TGZ} -C /tmp cd /tmp/${PY_INSTALLER_DIR} @@ -45,19 +45,19 @@ install_python() { make -j$($(nproc) + 1) make altinstall - # create symbolic links at PY_HOME + # Create symbolic links at PY_HOME ln -sf ${PY_HOME}/bin/python${PY_VERSION} ${PY_HOME}/bin/python${PY_MAJOR_VERSION} ln -sf ${PY_HOME}/bin/pip${PY_VERSION} ${PY_HOME}/bin/pip${PY_MAJOR_VERSION} ln -sf ${PY_HOME}/bin/python${PY_MAJOR_VERSION} ${PY_HOME}/bin/python ln -sf ${PY_HOME}/bin/pip${PY_MAJOR_VERSION} ${PY_HOME}/bin/pip - # clean up + # Clean up rm -rf /tmp/${PY_INSTALLER_TGZ} /tmp/${PY_INSTALLER_DIR} echo "Python ${PY_LATEST_VERSION} installation successful." ${PY_HOME}/bin/python -c "import sys; print(sys.version)" } -# create links +# Create symbolic links create_links() { ln -sf ${PY_HOME}/bin/python${PY_VERSION} /usr/bin/python${PY_VERSION} ln -sf ${PY_HOME}/bin/pip${PY_VERSION} /usr/bin/pip${PY_VERSION} diff --git a/pytorch/new.Dockerfile b/pytorch/new.Dockerfile index 7dff6076..49f2e7fa 100644 --- a/pytorch/new.Dockerfile +++ b/pytorch/new.Dockerfile @@ -1,6 +1,7 @@ -ARG BASE_NAME=ubuntu +ARG BASE_NAME=quay.io/ascend/cann ARG BASE_VERSION=latest -FROM ${BASE_NAME}:${BASE_VERSION} as builder + +FROM ${BASE_NAME}:${BASE_VERSION} as official # Arguments ARG PYTORCH_VERSION @@ -10,6 +11,6 @@ ARG TORCH_NPU_VERSION SHELL [ "/bin/bash", "-c" ] # Install PyTorch -RUN pip3 install --no-cache-dir \ +RUN pip install --no-cache-dir \ torch==${PYTORCH_VERSION} \ torch-npu==${TORCH_NPU_VERSION}