Skip to content

Commit

Permalink
v3: update
Browse files Browse the repository at this point in the history
  • Loading branch information
shink committed Jul 3, 2024
1 parent 383575f commit afc1f7e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions cann/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
LICENSE
README.md
Dockerfile.ubuntu
Dockerfile.openeuler
scripts/docker-entrypoint.sh
18 changes: 9 additions & 9 deletions cann/scripts/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand Down
7 changes: 4 additions & 3 deletions pytorch/new.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}

0 comments on commit afc1f7e

Please sign in to comment.