mindspore_cpu_install_en.md 6.1 KB
Newer Older
L
leiyuning 已提交
1 2
# MindSpore Installation Guide

昇思MindSpore's avatar
昇思MindSpore 已提交
3
This document describes how to quickly install MindSpore on a Ubuntu system with a CPU environment.
L
leiyuning 已提交
4 5 6 7 8 9 10 11

<!-- TOC -->

- [MindSpore Installation Guide](#mindspore-installation-guide)
    - [Environment Requirements](#environment-requirements)
        - [System Requirements and Software Dependencies](#system-requirements-and-software-dependencies)
        - [(Optional) Installing Conda](#optional-installing-conda)
    - [Installation Guide](#installation-guide)
12
        - [Installing Using Executable Files](#installing-using-executable-files)
L
leiyuning 已提交
13 14 15 16 17 18 19 20 21 22 23
        - [Installing Using the Source Code](#installing-using-the-source-code)
- [Installing MindArmour](#installing-mindarmour)

<!-- /TOC -->

## Environment Requirements

### System Requirements and Software Dependencies

| Version | Operating System | Executable File Installation Dependencies | Source Code Compilation and Installation Dependencies |
| ---- | :--- | :--- | :--- |
T
Ting Wang 已提交
24
| MindSpore 0.3.0-alpha | Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5 <br> - For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindspore/blob/r0.3/requirements.txt). | **Compilation dependencies:**<br> - [Python](https://www.python.org/downloads/) 3.7.5 <br> - [wheel](https://pypi.org/project/wheel/) >= 0.32.0 <br> - [GCC](https://gcc.gnu.org/releases.html) 7.3.0 <br> - [CMake](https://cmake.org/download/) >= 3.14.1 <br> - [patch](http://ftp.gnu.org/gnu/patch/) >= 2.5 <br> same as the executable file installation dependencies. |
L
leiyuning 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

- When Ubuntu version is 18.04, GCC 7.3.0 can be installed by using apt command.
- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.

### (Optional) Installing Conda

1. Download the Conda installation package from the following path:

   - [X86 Anaconda](https://www.anaconda.com/distribution/) or [X86 Miniconda](https://docs.conda.io/en/latest/miniconda.html)

2. Create and activate the Python environment.

    ```bash
    conda create -n {your_env_name} python=3.7.5
    conda activate {your_env_name}
    ```

> Conda is a powerful Python environment management tool. It is recommended that a beginner read related information on the Internet first.

## Installation Guide

46 47 48 49 50 51 52 53 54 55 56 57 58 59
### Installing Using Executable Files

1. Download the .whl package from the [MindSpore website](https://www.mindspore.cn/versions/en). It is recommended to perform SHA-256 integrity verification first and run the following command to install MindSpore:

    ```bash
    pip install mindspore-{version}-cp37-cp37m-linux_{arch}.whl
    ```

2. Run the following command. If no loading error message such as `No module named 'mindspore'` is displayed, the installation is successful.

    ```bash
    python -c 'import mindspore'
    ```

L
leiyuning 已提交
60 61 62 63 64
### Installing Using the Source Code

1. Download the source code from the code repository.

    ```bash
昇思MindSpore's avatar
昇思MindSpore 已提交
65
    git clone https://gitee.com/mindspore/mindspore.git -b r0.3
L
leiyuning 已提交
66
    ```
L
leonwanghui 已提交
67

L
leiyuning 已提交
68 69 70 71 72 73
2. Run the following command in the root directory of the source code to compile MindSpore:

    ```bash
    bash build.sh -e cpu -z -j4
    ```
    > - Before running the preceding command, ensure that the paths where the executable files cmake and patch store have been added to the environment variable PATH.
74
    > - In the build.sh script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
L
leiyuning 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87 88
    > - If the compiler performance is strong, you can add -j{Number of threads} in to script to increase the number of threads. For example, `bash build.sh -e cpu -z -j12`.

3. Run the following command to install MindSpore:

    ```bash
    chmod +x build/package/mindspore-{version}-cp37-cp37m-linux_{arch}.whl
    pip install build/package/mindspore-{version}-cp37-cp37m-linux_{arch}.whl
    ```

4. Run the following command. If no loading error message such as `No module named 'mindspore'` is displayed, the installation is successful.

    ```bash
    python -c 'import mindspore'
    ```
L
leonwanghui 已提交
89

L
leiyuning 已提交
90 91 92 93 94 95 96 97 98 99
# Installing MindArmour

If you need to conduct AI model security research or enhance the security of the model in you applications, you can install MindArmour.

## Environment Requirements

### System Requirements and Software Dependencies

| Version | Operating System | Executable File Installation Dependencies | Source Code Compilation and Installation Dependencies |
| ---- | :--- | :--- | :--- |
T
Ting Wang 已提交
100
| MindArmour 0.3.0-alpha | Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5 <br> - MindSpore 0.3.0-alpha <br> - For details about other dependency items, see [setup.py](https://gitee.com/mindspore/mindarmour/blob/r0.3/setup.py). | Same as the executable file installation dependencies. |
L
leiyuning 已提交
101 102 103 104 105

- When the network is connected, dependency items in the setup.py file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.

## Installation Guide

106 107 108 109 110 111 112 113 114 115 116 117 118 119
### Installing Using Executable Files

1. Download the .whl package from the [MindSpore website](https://www.mindspore.cn/versions/en). It is recommended to perform SHA-256 integrity verification first and run the following command to install MindArmour:

   ```bash
   pip install mindarmour-{version}-cp37-cp37m-linux_{arch}.whl
   ```

2. Run the following command. If no loading error message such as `No module named 'mindarmour'` is displayed, the installation is successful.

   ```bash
   python -c 'import mindarmour'
   ```

L
leiyuning 已提交
120 121 122 123 124
### Installing Using the Source Code

1. Download the source code from the code repository.

   ```bash
昇思MindSpore's avatar
昇思MindSpore 已提交
125
   git clone https://gitee.com/mindspore/mindarmour.git -b r0.3
L
leiyuning 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
   ```

2. Run the following command in the root directory of the source code to compile and install MindArmour:

   ```bash
   cd mindarmour
   python setup.py install
   ```


3. Run the following command. If no loading error message such as `No module named 'mindarmour'` is displayed, the installation is successful.

   ```bash
   python -c 'import mindarmour'
   ```