MindSpore nanny level installation tutorial

1. Introduction to MindSpore

Insert image description here

1 Introduction

MindSpore is an open source AI computing framework released by Huawei. A new generation of full-scenario AI computing framework launched in August 2019, MindSpore was announced as officially open source on March 28, 2020.
MindSpore overall architecture:

2.Features

  • Simple development experience: Help developers realize automatic network segmentation, and only need serial expression to achieve parallel training, lowering the threshold and simplifying the development process.
  • Flexible debugging mode:
    It has static execution and dynamic debugging capabilities during the training process. Developers can switch modes by changing a line of code and quickly locate problems online.
  • Give full play to the potential of the hardware
    and best match the Ascend processor to maximize the hardware capabilities, helping developers shorten training time and improve inference performance.
  • Rapid deployment in all scenarios
    supports rapid deployment on the cloud, edge and mobile phones, achieving better resource utilization and privacy protection, allowing developers to focus on the creation of AI applications.

The convenience of development has been relatively improved; at the same time, when debugging the code, we can quickly locate bugs; with Ascend's powerful processor, we do not need a lot of simulation testing and training, which can greatly improve our development efficiency; at the same time, the ecological environment Better, projects can be quickly deployed on mobile devices or in the cloud, allowing us to develop more safely and conveniently.

2. Install MindSpore

1. Get the installation command

Official download website: MindSpore Installation Guide

Select the corresponding download configuration

I am using Python 3.8 + MindSpore 1.9.0.
Insert image description here
If you are installing on a Linux system like me, but you don’t know your own kernel version, you can use the command uname -ato check your own Linux kernel version.
I am Linux-x86_64
Insert image description here

The official website documentation has detailed installation and environment configuration tutorials.

  • If you are installing MindSpore via pip on a brand new Ubuntu, you can use the automatic installation script for one-click installation. The automatic installation script will install MindSpore and its required dependencies.
  • If the system has already installed some dependencies, such as Python, GCC, etc., you can follow the manual installation steps to install them manually.

2. Automatic installation

The automatic installation will perform the following: (The automatic installation script only supports the installation of MindSpore>=1.6.0)

  • Change the software source configuration to Huawei Cloud Source.
  • Install the dependencies required by MindSpore, such as GCC.
  • Install Python3 and pip3 through APT and set them as default.
  • Install the MindSpore CPU version via pip.
  • After the automatic installation script is executed, you need to reopen the terminal window to make the environment variables take effect.
wget https://gitee.com/mindspore/mindspore/raw/r1.9/scripts/install/ubuntu-cpu-pip.sh
# 安装MindSpore 1.9.0和Python 3.7
MINDSPORE_VERSION=1.9.0 bash ./ubuntu-cpu-pip.sh
# 如需指定Python和MindSpore版本,以Python 3.9和MindSpore 1.6.0为例,使用以下方式
# PYTHON_VERSION=3.9 MINDSPORE_VERSION=1.6.0 bash ./ubuntu-cpu-pip.sh

3. Manual installation

The system environment and third-party dependencies required to install MindSpore are as follows:

name of software Version effect
Ubuntu 18.04 The operating system running MindSpore
Python 3.7-3.9 The use of MindSpore depends on the Python environment
GCC Between 7.3.0 and 9.4.0 C++ compiler for compiling MindSpore
(1) Install Python

Python can be installed in several ways. (To install other Python versions, just change 3.7 in the command)

Install Python via Conda

Install Miniconda:

cd /tmp
curl -O https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py37_4.10.3-Linux-$(arch).sh
bash Miniconda3-py37_4.10.3-Linux-$(arch).sh -b
cd -
. ~/miniconda3/etc/profile.d/conda.sh
conda init bash

Downloading using Conda in mainland China will be slower. After the installation is complete, you can set Tsinghua Source to accelerate downloading for Conda. You can refer to this: Anaconda Image Usage Help
Create a virtual environment, taking Python 3.7.5 as an example:

conda create -n mindspore_py37 python=3.7.5 -y
conda activate mindspore_py37

Install Python via APT
sudo apt-get update
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get install python3.7 python3.7-dev python3.7-distutils python3-pip -y
# 将新安装的Python设为默认
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 100
# 安装pip
python -m pip install pip -i https://repo.huaweicloud.com/repository/pypi/simple
sudo update-alternatives --install /usr/bin/pip pip ~/.local/bin/pip3.7 100
pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple

After the download is complete, you can check the python version:

python --version
(2) Install GCC
sudo apt-get install gcc -y
(3) Install MindSpore

Select the appropriate version according to the version and download it. Here we take MindSpore1.9.0 as an example.

export MS_VERSION=1.9.0

Then execute the following command to install MindSpore according to the system architecture and Python version.

# x86_64 + Python3.7
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MS_VERSION}/MindSpore/cpu/x86_64/mindspore-${MS_VERSION/-/}-cp37-cp37m-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# x86_64 + Python3.8
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MS_VERSION}/MindSpore/cpu/x86_64/mindspore-${MS_VERSION/-/}-cp38-cp38-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# x86_64 + Python3.9
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MS_VERSION}/MindSpore/cpu/x86_64/mindspore-${MS_VERSION/-/}-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# aarch64 + Python3.7
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MS_VERSION}/MindSpore/cpu/aarch64/mindspore-${MS_VERSION/-/}-cp37-cp37m-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# aarch64 + Python3.8
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MS_VERSION}/MindSpore/cpu/aarch64/mindspore-${MS_VERSION/-/}-cp38-cp38-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# aarch64 + Python3.9
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MS_VERSION}/MindSpore/cpu/aarch64/mindspore-${MS_VERSION/-/}-cp39-cp39-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple

4. Check whether the installation is successful

After entering python, execute the following command:

import mindspore;
mindspore.run_check()

If the output is as follows, the installation is successful!

MindSpore version: 版本号
The result of multiplication calculation is correct, MindSpore has been installed successfully!

5. Upgrade MindSpore version

If you need to upgrade the MindSpore version, just execute the command

pip install --upgrade mindspore=={
    
    version}

When upgrading to the rc version, you need to manually specify {version} as the rc version number, such as 1.6.0rc1; if upgrading to the official version, the =={version} field can be defaulted.

The installation is complete here~~You can enjoy your MindSpore journey~

Guess you like

Origin blog.csdn.net/m0_51662391/article/details/128021828