mindspore_gpu_install_en.md 10.7 KB
Newer Older
L
leiyuning 已提交
1 2 3 4 5 6 7 8 9 10 11 12
# MindSpore Installation Guide

This document describes how to quickly install MindSpore on a NVIDIA GPU environment.

<!-- TOC -->

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

<!-- /TOC -->

## Environment Requirements

### Hardware Requirements

- Nvidia GPU

### System Requirements and Software Dependencies

| Version | Operating System | Executable File Installation Dependencies | Source Code Compilation and Installation Dependencies |
| ---- | :--- | :--- | :--- |
T
Ting Wang 已提交
31
| MindSpore 0.5.0-beta | Ubuntu 18.04 x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5 <br> - [CUDA 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base) <br> - [CuDNN](https://developer.nvidia.com/rdp/cudnn-archive) >= 7.6 <br> - [OpenMPI](https://www.open-mpi.org/faq/?category=building#easy-build) 3.1.5 (optional, required for single-node/multi-GPU and multi-node/multi-GPU training) <br> - [NCCL](https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html#debian) 2.4.8-1 (optional, required for single-node/multi-GPU and multi-node/multi-GPU training) <br> - For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindspore/blob/r0.5/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> - [CMake](https://cmake.org/download/) >= 3.14.1 <br> - [GCC](https://gcc.gnu.org/releases.html) 7.3.0 <br> - [patch](http://ftp.gnu.org/gnu/patch/) >= 2.5 <br> - [Autoconf](https://www.gnu.org/software/autoconf) >= 2.69 <br> - [Libtool](https://www.gnu.org/software/libtool) >= 2.4.6-29.fc30 <br> - [Automake](https://www.gnu.org/software/automake) >= 1.15.1 <br> - [CUDA 9.2](https://developer.nvidia.com/cuda-92-download-archive) / [CUDA 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base) <br> - [CuDNN](https://developer.nvidia.com/rdp/cudnn-archive) >= 7.6 <br> **Installation dependencies:**<br> same as the executable file installation dependencies. |
L
leiyuning 已提交
32

L
lvmingfu 已提交
33
- 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.
Z
zhoufeng 已提交
34
- MindSpore reduces dependency on Autoconf, Libtool, Automake versions for the convenience of users, default versions of these tools built in their systems are now supported.
L
leiyuning 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

### (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

53 54 55 56 57
### Installing Using Executable Files

- 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
W
wukesong 已提交
58
    pip install mindspore_gpu-{version}-cp37-cp37m-linux_{arch}.whl
59 60
    ```

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

1. Download the source code from the code repository.

    ```bash
昇思MindSpore's avatar
昇思MindSpore 已提交
66
    git clone https://gitee.com/mindspore/mindspore.git -b r0.5
L
leiyuning 已提交
67 68 69 70
    ```

2. Run the following command in the root directory of the source code to compile MindSpore:
    ```bash
71
	bash build.sh -e gpu
L
leiyuning 已提交
72
    ```
L
lvmingfu 已提交
73 74
    > - 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.
    > - 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.
75
    > - In the `build.sh` script, the default number of compilation threads is 8. If the compiler performance is poor, compilation errors may occur. You can add -j{Number of threads} in to script to reduce the number of threads. For example, `bash build.sh -e gpu -j4`.
L
leiyuning 已提交
76 77 78 79

3. Run the following command to install MindSpore:

    ```bash
W
wukesong 已提交
80 81
    chmod +x build/package/mindspore_gpu-{version}-cp37-cp37m-linux_{arch}.whl
    pip install build/package/mindspore_gpu-{version}-cp37-cp37m-linux_{arch}.whl
L
leiyuning 已提交
82 83 84 85 86
    ```

## Installation Verification

- After Installation, execute the following Python script:
L
leonwanghui 已提交
87

L
leiyuning 已提交
88 89 90 91 92 93 94 95 96 97 98
    ```bash
    import numpy as np
    from mindspore import Tensor
    from mindspore.ops import functional as F
    import mindspore.context as context

    context.set_context(device_target="GPU")
    x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
    y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
    print(F.tensor_add(x, y))
    ```
L
leonwanghui 已提交
99

L
leiyuning 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
- The outputs should be same as:

    ```bash
    [[[ 2.  2.  2.  2.],
      [ 2.  2.  2.  2.],
      [ 2.  2.  2.  2.]],

     [[ 2.  2.  2.  2.],
      [ 2.  2.  2.  2.],
      [ 2.  2.  2.  2.]],

     [[ 2.  2.  2.  2.],
      [ 2.  2.  2.  2.],
      [ 2.  2.  2.  2.]]]
    ```

116 117 118 119 120 121 122 123 124 125
# Installing MindInsight

If you need to analyze information such as model scalars, graphs, and model traceback, you can install MindInsight.

## Environment Requirements

### System Requirements and Software Dependencies

| Version | Operating System | Executable File Installation Dependencies | Source Code Compilation and Installation Dependencies |
| ---- | :--- | :--- | :--- |
T
Ting Wang 已提交
126
| MindInsight 0.5.0-beta | - Ubuntu 18.04 x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5 <br> - MindSpore 0.5.0-beta <br> - For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindinsight/blob/r0.5/requirements.txt). | **Compilation dependencies:**<br> - [Python](https://www.python.org/downloads/) 3.7.5 <br> - [CMake](https://cmake.org/download/) >= 3.14.1 <br> - [GCC](https://gcc.gnu.org/releases.html) 7.3.0 <br> - [node.js](https://nodejs.org/en/download/) >= 10.19.0 <br> - [wheel](https://pypi.org/project/wheel/) >= 0.32.0 <br> - [pybind11](https://pypi.org/project/pybind11/) >= 2.4.3 <br> **Installation dependencies:**<br> same as the executable file installation dependencies. |
127

L
lvmingfu 已提交
128
- 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.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

## Installation Guide

### 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 MindInsight:

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

2. Run the following command. If `web address: http://127.0.0.1:8080` is displayed, the installation is successful.

    ```bash
    mindinsight start
    ```

### Installing Using the Source Code

1. Download the source code from the code repository.

    ```bash
昇思MindSpore's avatar
昇思MindSpore 已提交
151
    git clone https://gitee.com/mindspore/mindinsight.git -b r0.5
152
    ```
李鸿章 已提交
153
    > You are **not** supposed to obtain the source code from the zip package downloaded from the repository homepage.
154 155 156 157 158 159 160 161 162 163 164 165 166

2. Install MindInsight by using either of the following installation methods:

   (1) Access the root directory of the source code and run the following installation command:

      ```bash
      cd mindinsight
      pip install -r requirements.txt
      python setup.py install
      ```

   (2) Create a .whl package to install MindInsight.

李鸿章 已提交
167
      Access the root directory of the source code.
L
lvmingfu 已提交
168 169
      First run the MindInsight compilation script under the `build` directory of the source code.
      Then run the command to install the .whl package generated into the `output` directory of the source code.
170 171

      ```bash
李鸿章 已提交
172 173 174
      cd mindinsight
      bash build/build.sh
      pip install output/mindinsight-{version}-cp37-cp37m-linux_{arch}.whl
175 176 177 178 179 180 181 182
      ```

3. Run the following command. If `web address: http://127.0.0.1:8080` is displayed, the installation is successful.

    ```bash
    mindinsight start
    ```

L
leiyuning 已提交
183 184 185 186 187 188 189 190 191 192
# 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 已提交
193
| MindArmour 0.5.0-beta | Ubuntu 18.04 x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5 <br> - MindSpore 0.5.0-beta <br> - For details about other dependency items, see [setup.py](https://gitee.com/mindspore/mindarmour/blob/r0.5/setup.py). | Same as the executable file installation dependencies. |
L
leiyuning 已提交
194

L
lvmingfu 已提交
195
- 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.
L
leiyuning 已提交
196 197 198

## Installation Guide

199 200 201 202 203 204 205 206 207 208 209 210 211 212
### 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 已提交
213 214 215 216 217
### Installing Using the Source Code

1. Download the source code from the code repository.

   ```bash
昇思MindSpore's avatar
昇思MindSpore 已提交
218
   git clone https://gitee.com/mindspore/mindarmour.git -b r0.5
L
leiyuning 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231 232
   ```

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'
   ```