From cefb1b9ac7f765cd2d3df1a6516c6e2b895ada92 Mon Sep 17 00:00:00 2001 From: xulei Date: Thu, 31 Mar 2022 11:06:01 +0800 Subject: [PATCH] [scripts] check mindspore version --- scripts/install/euleros-ascend-conda.sh | 18 ++++++++++++++-- scripts/install/euleros-ascend-pip.sh | 20 ++++++++++-------- scripts/install/euleros-ascend310-pip.sh | 20 ++++++++++-------- scripts/install/ubuntu-cpu-conda.sh | 18 ++++++++++++++-- scripts/install/ubuntu-cpu-pip.sh | 25 +++++++++++++++-------- scripts/install/ubuntu-gpu-conda.sh | 17 +++++++++++++++- scripts/install/ubuntu-gpu-pip.sh | 26 ++++++++++++++++-------- 7 files changed, 107 insertions(+), 37 deletions(-) diff --git a/scripts/install/euleros-ascend-conda.sh b/scripts/install/euleros-ascend-conda.sh index 75c88f32abd..8c2d7ad4daa 100644 --- a/scripts/install/euleros-ascend-conda.sh +++ b/scripts/install/euleros-ascend-conda.sh @@ -22,12 +22,12 @@ # # Augments: # - PYTHON_VERSION: python version to set up. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0 # - OPENMPI: whether to install optional package Open MPI for distributed training. [on, off(default)] # # Usage: # Run script like `bash ./euleros-ascend-conda.sh`. -# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.5.0 bash ./euleros-ascend-conda.sh`. +# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.0 bash ./euleros-ascend-conda.sh`. set -e @@ -35,12 +35,26 @@ PYTHON_VERSION=${PYTHON_VERSION:-3.7} MINDSPORE_VERSION=${MINDSPORE_VERSION:-EMPTY} OPENMPI=${OPENMPI:-off} +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." + exit 1 +fi + available_py_version=(3.7 3.8 3.9) if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then echo "PYTHON_VERSION is '$PYTHON_VERSION', but available versions are [${available_py_version[*]}]." exit 1 fi +if [[ "$PYTHON_VERSION" == "3.8" && ${MINDSPORE_VERSION:0:3} == "1.6" ]]; then + echo "PYTHON_VERSION==3.8 is not compatible with MINDSPORE_VERSION==1.6.x, please use PYTHON_VERSION==3.7 or 3.9 for MINDSPORE_VERSION==1.6.x." + exit 1 +fi + # add value to environment variable if value is not in it add_env() { local name=$1 diff --git a/scripts/install/euleros-ascend-pip.sh b/scripts/install/euleros-ascend-pip.sh index f24f3aa9e3b..fcd0a6adad1 100644 --- a/scripts/install/euleros-ascend-pip.sh +++ b/scripts/install/euleros-ascend-pip.sh @@ -22,12 +22,12 @@ # # Augments: # - PYTHON_VERSION: python version to set up. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install, required +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0, required # - OPENMPI: whether to install optional package Open MPI for distributed training. [on, off(default)] # # Usage: -# Run script like `MINDSPORE_VERSION=1.6.1 bash ./euleros-ascend-pip.sh`. -# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.5.0 bash ./euleros-ascend-pip.sh`. +# Run script like `MINDSPORE_VERSION=1.7.0 bash ./euleros-ascend-pip.sh`. +# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.0 bash ./euleros-ascend-pip.sh`. set -e @@ -35,8 +35,12 @@ PYTHON_VERSION=${PYTHON_VERSION:-3.7} MINDSPORE_VERSION=${MINDSPORE_VERSION:-EMPTY} OPENMPI=${OPENMPI:-off} -if [[ $MINDSPORE_VERSION == "EMPTY" ]]; then - echo "MINDSPORE_VERSION not set, please check available versions at https://www.mindspore.cn/versions." +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if [ $MINDSPORE_VERSION == "EMPTY" ] || version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." exit 1 fi @@ -47,9 +51,9 @@ if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then fi declare -A version_map=() -version_map["3.7"]="${MINDSPORE_VERSION}-cp37-cp37m" -version_map["3.8"]="${MINDSPORE_VERSION}-cp38-cp38" -version_map["3.9"]="${MINDSPORE_VERSION}-cp39-cp39" +version_map["3.7"]="${MINDSPORE_VERSION/-/}-cp37-cp37m" +version_map["3.8"]="${MINDSPORE_VERSION/-/}-cp38-cp38" +version_map["3.9"]="${MINDSPORE_VERSION/-/}-cp39-cp39" # add value to environment variable if value is not in it add_env() { diff --git a/scripts/install/euleros-ascend310-pip.sh b/scripts/install/euleros-ascend310-pip.sh index 44f931a7173..a4554d54bf9 100644 --- a/scripts/install/euleros-ascend310-pip.sh +++ b/scripts/install/euleros-ascend310-pip.sh @@ -22,11 +22,11 @@ # # Augments: # - PYTHON_VERSION: python version to set up. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install, required +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0, required # # Usage: -# Run script like `MINDSPORE_VERSION=1.6.1 bash ./euleros-ascend310-pip.sh`. -# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.5.0 bash ./euleros-ascend310-pip.sh`. +# Run script like `MINDSPORE_VERSION=1.7.0 bash ./euleros-ascend310-pip.sh`. +# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.0 bash ./euleros-ascend310-pip.sh`. set -e @@ -34,8 +34,12 @@ PYTHON_VERSION=${PYTHON_VERSION:-3.7} MINDSPORE_VERSION=${MINDSPORE_VERSION:-EMPTY} OPENMPI=${OPENMPI:-off} -if [[ $MINDSPORE_VERSION == "EMPTY" ]]; then - echo "MINDSPORE_VERSION not set, please check available versions at https://www.mindspore.cn/versions." +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if [ $MINDSPORE_VERSION == "EMPTY" ] || version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." exit 1 fi @@ -46,9 +50,9 @@ if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then fi declare -A version_map=() -version_map["3.7"]="${MINDSPORE_VERSION}-cp37-cp37m" -version_map["3.8"]="${MINDSPORE_VERSION}-cp38-cp38" -version_map["3.9"]="${MINDSPORE_VERSION}-cp39-cp39" +version_map["3.7"]="${MINDSPORE_VERSION/-/}-cp37-cp37m" +version_map["3.8"]="${MINDSPORE_VERSION/-/}-cp38-cp38" +version_map["3.9"]="${MINDSPORE_VERSION/-/}-cp39-cp39" # add value to environment variable if value is not in it add_env() { diff --git a/scripts/install/ubuntu-cpu-conda.sh b/scripts/install/ubuntu-cpu-conda.sh index e6041fbc4bb..3ca7440cf0e 100644 --- a/scripts/install/ubuntu-cpu-conda.sh +++ b/scripts/install/ubuntu-cpu-conda.sh @@ -24,23 +24,37 @@ # # Augments: # - PYTHON_VERSION: python version to set up. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0 # # Usage: # Run script like `bash ./ubuntu-cpu-conda.sh`. -# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.5.0 bash ./ubuntu-cpu-conda.sh`. +# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.0 bash ./ubuntu-cpu-conda.sh`. set -e PYTHON_VERSION=${PYTHON_VERSION:-3.7} MINDSPORE_VERSION=${MINDSPORE_VERSION:-EMPTY} +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." + exit 1 +fi + available_py_version=(3.7 3.8 3.9) if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then echo "PYTHON_VERSION is '$PYTHON_VERSION', but available versions are [${available_py_version[*]}]." exit 1 fi +if [[ "$PYTHON_VERSION" == "3.8" && ${MINDSPORE_VERSION:0:3} == "1.6" ]]; then + echo "PYTHON_VERSION==3.8 is not compatible with MINDSPORE_VERSION==1.6.x, please use PYTHON_VERSION==3.7 or 3.9 for MINDSPORE_VERSION==1.6.x." + exit 1 +fi + install_conda() { conda_file_name="Miniconda3-py3${PYTHON_VERSION##*.}_4.10.3-Linux-$(arch).sh" cd /tmp diff --git a/scripts/install/ubuntu-cpu-pip.sh b/scripts/install/ubuntu-cpu-pip.sh index a0e0838d6d3..7b02fd88369 100644 --- a/scripts/install/ubuntu-cpu-pip.sh +++ b/scripts/install/ubuntu-cpu-pip.sh @@ -24,19 +24,23 @@ # # Augments: # - PYTHON_VERSION: python version to install. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install, required +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0, required # # Usage: -# Run script like `MINDSPORE_VERSION=1.6.1 bash ./ubuntu-cpu-pip.sh`. -# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.5.0 bash ./ubuntu-cpu-pip.sh`. +# Run script like `MINDSPORE_VERSION=1.7.0 bash ./ubuntu-cpu-pip.sh`. +# To set augments, run it as `PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.0 bash ./ubuntu-cpu-pip.sh`. set -e PYTHON_VERSION=${PYTHON_VERSION:-3.7} MINDSPORE_VERSION=${MINDSPORE_VERSION:-EMPTY} -if [[ $MINDSPORE_VERSION == "EMPTY" ]]; then - echo "MINDSPORE_VERSION not set, please check available versions at https://www.mindspore.cn/versions." +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if [ $MINDSPORE_VERSION == "EMPTY" ] || version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." exit 1 fi @@ -46,10 +50,15 @@ if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then exit 1 fi +if [[ "$PYTHON_VERSION" == "3.8" && ${MINDSPORE_VERSION:0:3} == "1.6" ]]; then + echo "PYTHON_VERSION==3.8 is not compatible with MINDSPORE_VERSION==1.6.x, please use PYTHON_VERSION==3.7 or 3.9 for MINDSPORE_VERSION==1.6.x." + exit 1 +fi + declare -A version_map=() -version_map["3.7"]="${MINDSPORE_VERSION}-cp37-cp37m" -version_map["3.8"]="${MINDSPORE_VERSION}-cp38-cp38" -version_map["3.9"]="${MINDSPORE_VERSION}-cp39-cp39" +version_map["3.7"]="${MINDSPORE_VERSION/-/}-cp37-cp37m" +version_map["3.8"]="${MINDSPORE_VERSION/-/}-cp38-cp38" +version_map["3.9"]="${MINDSPORE_VERSION/-/}-cp39-cp39" # use huaweicloud mirror in China sudo sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list diff --git a/scripts/install/ubuntu-gpu-conda.sh b/scripts/install/ubuntu-gpu-conda.sh index c52bec8a12d..5926deee465 100644 --- a/scripts/install/ubuntu-gpu-conda.sh +++ b/scripts/install/ubuntu-gpu-conda.sh @@ -25,7 +25,7 @@ # # Augments: # - PYTHON_VERSION: python version to install. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0 # - CUDA_VERSION: CUDA version to install. [10.1, 11.1(default)] # - OPENMPI: whether to install optional package Open MPI for distributed training. [on, off(default)] # @@ -40,11 +40,26 @@ MINDSPORE_VERSION=${MINDSPORE_VERSION:-EMPTY} CUDA_VERSION=${CUDA_VERSION:-11.1} OPENMPI=${OPENMPI:-off} +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." + exit 1 +fi + available_py_version=(3.7 3.8 3.9) if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then echo "PYTHON_VERSION is '$PYTHON_VERSION', but available versions are [${available_py_version[*]}]." exit 1 fi + +if [[ "$PYTHON_VERSION" == "3.8" && ${MINDSPORE_VERSION:0:3} == "1.6" ]]; then + echo "PYTHON_VERSION==3.8 is not compatible with MINDSPORE_VERSION==1.6.x, please use PYTHON_VERSION==3.7 or 3.9 for MINDSPORE_VERSION==1.6.x." + exit 1 +fi + available_cuda_version=(10.1 11.1) if [[ " ${available_cuda_version[*]} " != *" $CUDA_VERSION "* ]]; then echo "CUDA_VERSION is '$CUDA_VERSION', but available versions are [${available_cuda_version[*]}]." diff --git a/scripts/install/ubuntu-gpu-pip.sh b/scripts/install/ubuntu-gpu-pip.sh index 7736b8c736e..d0f7efb1737 100644 --- a/scripts/install/ubuntu-gpu-pip.sh +++ b/scripts/install/ubuntu-gpu-pip.sh @@ -26,13 +26,13 @@ # # Augments: # - PYTHON_VERSION: python version to install. [3.7(default), 3.8, 3.9] -# - MINDSPORE_VERSION: mindspore version to install, required +# - MINDSPORE_VERSION: mindspore version to install, >=1.6.0, required # - CUDA_VERSION: CUDA version to install. [10.1, 11.1(default)] # - OPENMPI: whether to install optional package Open MPI for distributed training. [on, off(default)] # # Usage: -# Run script like `MINDSPORE_VERSION=1.6.1 bash -i ./ubuntu-gpu-pip.sh`. -# To set augments, run it as `MINDSPORE_VERSION=1.5.0 CUDA_VERSION=10.1 OPENMPI=on bash -i ./ubuntu-gpu-pip.sh`. +# Run script like `MINDSPORE_VERSION=1.7.0 bash -i ./ubuntu-gpu-pip.sh`. +# To set augments, run it as `MINDSPORE_VERSION=1.6.0 CUDA_VERSION=10.1 OPENMPI=on bash -i ./ubuntu-gpu-pip.sh`. set -e @@ -41,8 +41,12 @@ MINDSPORE_VERSION=${MINDSPORE_VERSION:EMPTY} CUDA_VERSION=${CUDA_VERSION:-11.1} OPENMPI=${OPENMPI:-off} -if [[ $MINDSPORE_VERSION == "EMPTY" ]]; then - echo "MINDSPORE_VERSION not set, please check available versions at https://www.mindspore.cn/versions." +version_less() { + test "$(echo "$@" | tr ' ' '\n' | sort -rV | head -n 1)" != "$1"; +} + +if [ $MINDSPORE_VERSION == "EMPTY" ] || version_less "${MINDSPORE_VERSION}" "1.6.0"; then + echo "MINDSPORE_VERSION should be >=1.6.0, please check available versions at https://www.mindspore.cn/versions." exit 1 fi @@ -51,6 +55,12 @@ if [[ " ${available_py_version[*]} " != *" $PYTHON_VERSION "* ]]; then echo "PYTHON_VERSION is '$PYTHON_VERSION', but available versions are [${available_py_version[*]}]." exit 1 fi + +if [[ "$PYTHON_VERSION" == "3.8" && ${MINDSPORE_VERSION:0:3} == "1.6" ]]; then + echo "PYTHON_VERSION==3.8 is not compatible with MINDSPORE_VERSION==1.6.x, please use PYTHON_VERSION==3.7 or 3.9 for MINDSPORE_VERSION==1.6.x." + exit 1 +fi + available_cuda_version=(10.1 11.1) if [[ " ${available_cuda_version[*]} " != *" $CUDA_VERSION "* ]]; then echo "CUDA_VERSION is '$CUDA_VERSION', but available versions are [${available_cuda_version[*]}]." @@ -68,9 +78,9 @@ fi cuda_name="cuda-$CUDA_VERSION" declare -A version_map=() -version_map["3.7"]="${MINDSPORE_VERSION}-cp37-cp37m" -version_map["3.8"]="${MINDSPORE_VERSION}-cp38-cp38" -version_map["3.9"]="${MINDSPORE_VERSION}-cp39-cp39" +version_map["3.7"]="${MINDSPORE_VERSION/-/}-cp37-cp37m" +version_map["3.8"]="${MINDSPORE_VERSION/-/}-cp38-cp38" +version_map["3.9"]="${MINDSPORE_VERSION/-/}-cp39-cp39" # add value to environment variable if value is not in it add_env() {