• Home
Name Date Size #Lines LOC

..--

interfaces/kits/c/12-May-2024-1,669694

patches/12-May-2024-45,03644,426

test/12-May-2024-3,2722,469

.gitignoreD12-May-20241.6 KiB11092

BUILD.gnD12-May-20241.7 KiB6656

LICENSED12-May-202411.1 KiB202169

OAT.xmlD12-May-20246.5 KiB9038

README.OpenSourceD12-May-2024418 1211

README.mdD12-May-202415.6 KiB307221

README_CN.mdD12-May-202416.8 KiB377268

build_helper.pyD12-May-20242.4 KiB8263

bundle.jsonD12-May-20242.3 KiB8988

README.OpenSource

1[
2  {
3    "Name": "MindSpore",
4    "License": "Apache License 2.0",
5    "License File": "LICENSE.txt",
6    "Version Number": "2.1.0",
7    "Owner": "chengfeng27@huawei.com",
8    "Upstream URL": "https://gitee.com/mindspore/mindspore/repository/archive/v2.1.0",
9    "Description": "MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios."
10  }
11]
12

README.md

1![MindSpore Logo](https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-logo.png "MindSpore logo")
2
3[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mindspore.svg)](https://pypi.org/project/mindspore)
4[![PyPI](https://badge.fury.io/py/mindspore.svg)](https://badge.fury.io/py/mindspore)
5[![Downloads](https://pepy.tech/badge/mindspore)](https://pepy.tech/project/mindspore)
6[![DockerHub](https://img.shields.io/docker/pulls/mindspore/mindspore-cpu.svg)](https://hub.docker.com/r/mindspore/mindspore-cpu)
7[![LICENSE](https://img.shields.io/github/license/mindspore-ai/mindspore.svg?style=flat-square)](https://github.com/mindspore-ai/mindspore/blob/master/LICENSE)
8[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w)
9[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gitee.com/mindspore/mindspore/pulls)
10
11[查看中文](./README_CN.md)
12
13<!-- TOC -->
14
15- [What Is MindSpore](#what-is-mindspore)
16    - [Automatic Differentiation](#automatic-differentiation)
17    - [Automatic Parallel](#automatic-parallel)
18- [Installation](#installation)
19    - [Pip mode method installation](#pip-mode-method-installation)
20    - [Source code compilation installation](#source-code-compilation-installation)
21    - [Docker Image](#docker-image)
22- [Quickstart](#quickstart)
23- [Docs](#docs)
24- [Community](#community)
25    - [Governance](#governance)
26    - [Communication](#communication)
27- [Contributing](#contributing)
28- [Maintenance phases](#maintenance-phases)
29- [Maintenance status](#maintenance-status)
30- [Release Notes](#release-notes)
31- [License](#license)
32
33<!-- /TOC -->
34
35## What Is MindSpore
36
37MindSpore is a new open source deep learning training/inference framework that
38could be used for mobile, edge and cloud scenarios. MindSpore is designed to
39provide development experience with friendly design and efficient execution for
40the data scientists and algorithmic engineers, native support for Ascend AI
41processor, and software hardware co-optimization. At the meantime MindSpore as
42a global AI open source community, aims to further advance the development and
43enrichment of the AI software/hardware application ecosystem.
44
45<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-architecture.png" alt="MindSpore Architecture"/>
46
47For more details please check out our [Architecture Guide](https://www.mindspore.cn/tutorials/en/master/beginner/introduction.html).
48
49### Automatic Differentiation
50
51Currently, there are two automatic differentiation techniques in mainstream deep learning frameworks:
52
53- **Operator Overloading (OO)**: Overloading the basic operators of the programming language to encapsulate their gradient rules. Record the operation trajectory of the network during forward execution in an operator overloaded manner, then apply the chain rule to the dynamically generated data flow graph to implement automatic differentiation.
54- **Source Transformation (ST)**: This technology is evolving from the functional programming framework and performs automatic differential transformation on the intermediate expression (the expression form of the program during the compilation process) in the form of just-in-time compilation (JIT), supporting complex control flow scenarios, higher-order functions and closures.
55
56PyTorch used OO. Compared to ST, OO generates gradient graph in runtime, so it does not need to take function call and control flow into consideration, which makes it easier to develop. However, OO can not perform gradient graph optimization in compilation time and the control flow has to be unfolded in runtime, so it is difficult to achieve extreme optimization in performance.
57
58MindSpore implemented automatic differentiation based on ST. On the one hand, it supports automatic differentiation of automatic control flow, so it is quite convenient to build models like PyTorch. On the other hand, MindSpore can perform static compilation optimization on neural networks to achieve great performance.
59
60<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>
61
62The implementation of MindSpore automatic differentiation can be understood as the symbolic differentiation of the program itself. Because MindSpore IR is a functional intermediate expression, it has an intuitive correspondence with the composite function in basic algebra. The derivation formula of the composite function composed of arbitrary basic functions can be derived. Each primitive operation in MindSpore IR can correspond to the basic functions in basic algebra, which can build more complex flow control.
63
64### Automatic Parallel
65
66The goal of MindSpore automatic parallel is to build a training method that combines data parallelism, model parallelism, and hybrid parallelism. It can automatically select a least cost model splitting strategy to achieve automatic distributed parallel training.
67
68<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>
69
70At present, MindSpore uses a fine-grained parallel strategy of splitting operators, that is, each operator in the figure is split into a cluster to complete parallel operations. The splitting strategy during this period may be very complicated, but as a developer advocating Pythonic, you don't need to care about the underlying implementation, as long as the top-level API compute is efficient.
71
72## Installation
73
74### Pip mode method installation
75
76MindSpore offers build options across multiple backends:
77
78| Hardware Platform | Operating System | Status |
79| :---------------- | :--------------- | :----- |
80| Ascend910 | Ubuntu-x86 | ✔️ |
81|  | Ubuntu-aarch64 | ✔️ |
82|  | EulerOS-aarch64 | ✔️ |
83|  | CentOS-x86 | ✔️ |
84|  | CentOS-aarch64 | ✔️ |
85| GPU CUDA 10.1 | Ubuntu-x86 | ✔️ |
86| CPU | Ubuntu-x86 | ✔️ |
87|  | Ubuntu-aarch64 | ✔️ |
88|  | Windows-x86 | ✔️ |
89
90For installation using `pip`, take `CPU` and `Ubuntu-x86` build version as an example:
91
921. Download whl from [MindSpore download page](https://www.mindspore.cn/versions/en), and install the package.
93
94    ```bash
95    pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindSpore/cpu/ubuntu_x86/mindspore-1.2.0rc1-cp37-cp37m-linux_x86_64.whl
96    ```
97
982. Run the following command to verify the install.
99
100    ```python
101    import numpy as np
102    import mindspore.context as context
103    import mindspore.nn as nn
104    from mindspore import Tensor
105    from mindspore.ops import operations as P
106
107    context.set_context(mode=context.GRAPH_MODE, device_target="CPU")
108
109    class Mul(nn.Cell):
110        def __init__(self):
111            super(Mul, self).__init__()
112            self.mul = P.Mul()
113
114        def construct(self, x, y):
115            return self.mul(x, y)
116
117    x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
118    y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))
119
120    mul = Mul()
121    print(mul(x, y))
122    ```
123
124    ```text
125    [ 4. 10. 18.]
126    ```
127
128Use pip mode method to install MindSpore in different environments. Refer to the following documents.
129
130- [Using pip mode method to install MindSpore in Ascend environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_pip_en.md)
131- [Using pip mode method to install MindSpore in GPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_pip_en.md)
132- [Using pip mode method to install MindSpore in CPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_pip_en.md)
133
134### Source code compilation installation
135
136Use the source code compilation method to install MindSpore in different environments. Refer to the following documents.
137
138- [Using the source code compilation method to install MindSpore in Ascend environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_source_en.md)
139- [Using the source code compilation method to install MindSpore in GPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_source_en.md)
140- [Using the source code compilation method to install MindSpore in CPU environment](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_source_en.md)
141
142### Docker Image
143
144MindSpore docker image is hosted on [Docker Hub](https://hub.docker.com/r/mindspore),
145currently the containerized build options are supported as follows:
146
147| Hardware Platform | Docker Image Repository | Tag | Description |
148| :---------------- | :---------------------- | :-- | :---------- |
149| CPU | `mindspore/mindspore-cpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` CPU release. |
150|  |  | `devel` | Development environment provided to build MindSpore (with `CPU` backend) from the source, refer to <https://www.mindspore.cn/install/en> for installation details. |
151|  |  | `runtime` | Runtime environment provided to install MindSpore binary package with `CPU` backend. |
152| GPU | `mindspore/mindspore-gpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` GPU release. |
153|  |  | `devel` | Development environment provided to build MindSpore (with `GPU CUDA10.1` backend) from the source, refer to <https://www.mindspore.cn/install/en> for installation details. |
154|  |  | `runtime` | Runtime environment provided to install MindSpore binary package with `GPU CUDA10.1` backend. |
155
156> **NOTICE:** For GPU `devel` docker image, it's NOT suggested to directly install the whl package after building from the source, instead we strongly RECOMMEND you transfer and install the whl package inside GPU `runtime` docker image.
157
158- CPU
159
160    For `CPU` backend, you can directly pull and run the latest stable image using the below command:
161
162    ```bash
163    docker pull mindspore/mindspore-cpu:1.1.0
164    docker run -it mindspore/mindspore-cpu:1.1.0 /bin/bash
165    ```
166
167- GPU
168
169    For `GPU` backend, please make sure the `nvidia-container-toolkit` has been installed in advance, here are some install guidelines for `Ubuntu` users:
170
171    ```bash
172    DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
173    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
174    curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
175
176    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
177    sudo systemctl restart docker
178    ```
179
180    Then edit the file daemon.json:
181
182    ```bash
183    $ vim /etc/docker/daemon.json
184    {
185        "runtimes": {
186            "nvidia": {
187                "path": "nvidia-container-runtime",
188                "runtimeArgs": []
189            }
190        }
191    }
192    ```
193
194    Restart docker again:
195
196    ```bash
197    sudo systemctl daemon-reload
198    sudo systemctl restart docker
199    ```
200
201    Then you can pull and run the latest stable image using the below command:
202
203    ```bash
204    docker pull mindspore/mindspore-gpu:1.1.0
205    docker run -it -v /dev/shm:/dev/shm --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.1.0 /bin/bash
206    ```
207
208    To test if the docker image works, please execute the python code below and check the output:
209
210    ```python
211    import numpy as np
212    import mindspore.context as context
213    from mindspore import Tensor
214    from mindspore.ops import functional as F
215
216    context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
217
218    x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
219    y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
220    print(F.tensor_add(x, y))
221    ```
222
223    ```text
224    [[[ 2.  2.  2.  2.],
225    [ 2.  2.  2.  2.],
226    [ 2.  2.  2.  2.]],
227
228    [[ 2.  2.  2.  2.],
229    [ 2.  2.  2.  2.],
230    [ 2.  2.  2.  2.]],
231
232    [[ 2.  2.  2.  2.],
233    [ 2.  2.  2.  2.],
234    [ 2.  2.  2.  2.]]]
235    ```
236
237If you want to learn more about the building process of MindSpore docker images,
238please check out [docker](https://gitee.com/mindspore/mindspore/blob/master/scripts/docker/README.md) repo for the details.
239
240## Quickstart
241
242See the [Quick Start](https://www.mindspore.cn/tutorials/en/master/beginner/quick_start.html)
243to implement the image classification.
244
245## Docs
246
247More details about installation guide, tutorials and APIs, please see the
248[User Documentation](https://gitee.com/mindspore/docs).
249
250## Community
251
252### Governance
253
254Check out how MindSpore Open Governance [works](https://gitee.com/mindspore/community/blob/master/governance.md).
255
256### Communication
257
258- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) - Communication platform for developers.
259- IRC channel at `#mindspore` (only for meeting minutes logging purpose)
260- Video Conferencing: TBD
261- Mailing-list: <https://mailweb.mindspore.cn/postorius/lists>
262
263## Contributing
264
265Welcome contributions. See our [Contributor Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md) for
266more details.
267
268## Maintenance phases
269
270Project stable branches will be in one of the following states:
271
272| **State**       | **Time frame**    | **Summary**                                          |
273|-------------|---------------|--------------------------------------------------|
274| Planning    | 1 - 3 months  | Features are under planning.                     |
275| Development | 3 months      | Features are under development.                  |
276| Maintained  | 6 - 12 months | All bugfixes are appropriate. Releases produced. |
277| Unmaintained| 0 - 3 months  | All bugfixes are appropriate. No Maintainers and No Releases produced.                                                 |
278| End Of Life (EOL) |  N/A |  Branch no longer accepting changes.    |
279
280## Maintenance status
281
282| **Branch** | **Status**   | **Initial Release Date** | **Next Phase**                         | **EOL Date**|
283|------------|--------------|--------------------------|----------------------------------------|-------------|
284| **r1.8**   | Maintained   | 2022-07-29               | Unmaintained <br> 2023-07-29 estimated |             |
285| **r1.7**   | Maintained   | 2022-04-29               | Unmaintained <br> 2023-04-29 estimated |             |
286| **r1.6**   | Maintained   | 2022-01-29               | Unmaintained <br> 2023-01-29 estimated |             |
287| **r1.5**   | Maintained   | 2021-10-15               | Unmaintained <br> 2022-10-15 estimated |             |
288| **r1.4**   | Maintained   | 2021-08-15               | Unmaintained <br> 2022-08-15 estimated |             |
289| **r1.3**   | End Of Life  | 2021-07-15               |                                        | 2022-07-15  |
290| **r1.2**   | End Of Life  | 2021-04-15               |                                        | 2022-04-29  |
291| **r1.1**   | End Of Life  | 2020-12-31               |                                        | 2021-09-30  |
292| **r1.0**   | End Of Life  | 2020-09-24               |                                        | 2021-07-30  |
293| **r0.7**   | End Of Life  | 2020-08-31               |                                        | 2021-02-28  |
294| **r0.6**   | End Of Life  | 2020-07-31               |                                        | 2020-12-30  |
295| **r0.5**   | End Of Life  | 2020-06-30               |                                        | 2021-06-30  |
296| **r0.3**   | End Of Life  | 2020-05-31               |                                        | 2020-09-30  |
297| **r0.2**   | End Of Life  | 2020-04-30               |                                        | 2020-08-31  |
298| **r0.1**   | End Of Life  | 2020-03-28               |                                        | 2020-06-30  |
299
300## Release Notes
301
302The release notes, see our [RELEASE](https://gitee.com/mindspore/mindspore/blob/master/RELEASE.md).
303
304## License
305
306[Apache License 2.0](https://gitee.com/mindspore/mindspore/blob/master/LICENSE)
307

README_CN.md

1![MindSpore标志](https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-logo.png "MindSpore logo")
2
3[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mindspore.svg)](https://pypi.org/project/mindspore)
4[![PyPI](https://badge.fury.io/py/mindspore.svg)](https://badge.fury.io/py/mindspore)
5[![Downloads](https://pepy.tech/badge/mindspore)](https://pepy.tech/project/mindspore)
6[![DockerHub](https://img.shields.io/docker/pulls/mindspore/mindspore-cpu.svg)](https://hub.docker.com/r/mindspore/mindspore-cpu)
7[![LICENSE](https://img.shields.io/github/license/mindspore-ai/mindspore.svg?style=flat-square)](https://github.com/mindspore-ai/mindspore/blob/master/LICENSE)
8[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w)
9[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://gitee.com/mindspore/mindspore/pulls)
10
11[View English](./README.md)
12
13<!-- TOC -->
14
15- [MindSpore介绍](#mindspore介绍)
16    - [自动微分](#自动微分)
17    - [自动并行](#自动并行)
18- [安装](#安装)
19    - [pip方式安装](#pip方式安装)
20    - [源码编译方式安装](#源码编译方式安装)
21    - [Docker镜像](#docker镜像)
22- [快速入门](#快速入门)
23- [文档](#文档)
24- [社区](#社区)
25    - [治理](#治理)
26    - [交流](#交流)
27- [贡献](#贡献)
28- [分支维护策略](#分支维护策略)
29- [现有分支维护状态](#现有分支维护状态)
30- [版本说明](#版本说明)
31- [许可证](#许可证)
32
33<!-- /TOC -->
34
35## MindSpore介绍
36
37MindSpore是一种适用于端边云场景的新型开源深度学习训练/推理框架。
38MindSpore提供了友好的设计和高效的执行,旨在提升数据科学家和算法工程师的开发体验,并为Ascend AI处理器提供原生支持,以及软硬件协同优化。
39
40同时,MindSpore作为全球AI开源社区,致力于进一步开发和丰富AI软硬件应用生态。
41
42<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/MindSpore-architecture-zh.png" alt="MindSpore Architecture"/>
43
44欲了解更多详情,请查看我们的[总体架构](https://www.mindspore.cn/tutorials/zh-CN/master/beginner/introduction.html)45
46### 自动微分
47
48当前主流深度学习框架中有两种自动微分技术:
49
50- **操作符重载法**: 通过操作符重载对编程语言中的基本操作语义进行重定义,封装其微分规则。 在程序运行时记录算子过载正向执行时网络的运行轨迹,对动态生成的数据流图应用链式法则,实现自动微分。
51- **代码变换法**: 该技术是从功能编程框架演进而来,以即时编译(Just-in-time Compilation,JIT)的形式对中间表达式(程序在编译过程中的表达式)进行自动差分转换,支持复杂的控制流场景、高阶函数和闭包。
52
53PyTorch采用的是操作符重载法。相较于代码变换法,操作符重载法是在运行时生成微分计算图的, 无需考虑函数调用与控制流等情况, 开发更为简单。 但该方法不能在编译时刻做微分图的优化, 控制流也需要根据运行时的信息来展开, 很难实现性能的极限优化。
54
55MindSpore则采用的是代码变换法。一方面,它支持自动控制流的自动微分,因此像PyTorch这样的模型构建非常方便。另一方面,MindSpore可以对神经网络进行静态编译优化,以获得更好的性能。
56
57<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>
58
59MindSpore自动微分的实现可以理解为程序本身的符号微分。MindSpore IR是一个函数中间表达式,它与基础代数中的复合函数具有直观的对应关系。复合函数的公式由任意可推导的基础函数组成。MindSpore IR中的每个原语操作都可以对应基础代数中的基本功能,从而可以建立更复杂的流控制。
60
61### 自动并行
62
63MindSpore自动并行的目的是构建数据并行、模型并行和混合并行相结合的训练方法。该方法能够自动选择开销最小的模型切分策略,实现自动分布并行训练。
64
65<img src="https://gitee.com/mindspore/mindspore/raw/master/docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>
66
67目前MindSpore采用的是算子切分的细粒度并行策略,即图中的每个算子被切分为一个集群,完成并行操作。在此期间的切分策略可能非常复杂,但是作为一名Python开发者,您无需关注底层实现,只要顶层API计算是有效的即可。
68
69## 安装
70
71### pip方式安装
72
73MindSpore提供跨多个后端的构建选项:
74
75| 硬件平台      | 操作系统        | 状态  |
76| :------------ | :-------------- | :--- |
77| Ascend 910    | Ubuntu-x86      | ✔️   |
78|               | Ubuntu-aarch64  | ✔️   |
79|               | EulerOS-aarch64 | ✔️   |
80|               | CentOS-x86      | ✔️   |
81|               | CentOS-aarch64  | ✔️   |
82| GPU CUDA 10.1 | Ubuntu-x86      | ✔️   |
83| CPU           | Ubuntu-x86      | ✔️   |
84|               | Ubuntu-aarch64  | ✔️   |
85|               | Windows-x86     | ✔️   |
86
87使用`pip`命令安装,以`CPU`和`Ubuntu-x86`build版本为例:
88
891. 请从[MindSpore下载页面](https://www.mindspore.cn/versions)下载并安装whl包。
90
91    ```bash
92    pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.2.0-rc1/MindSpore/cpu/ubuntu_x86/mindspore-1.2.0rc1-cp37-cp37m-linux_x86_64.whl
93    ```
94
952. 执行以下命令,验证安装结果。
96
97    ```python
98    import numpy as np
99    import mindspore.context as context
100    import mindspore.nn as nn
101    from mindspore import Tensor
102    from mindspore.ops import operations as P
103
104    context.set_context(mode=context.GRAPH_MODE, device_target="CPU")
105
106    class Mul(nn.Cell):
107        def __init__(self):
108            super(Mul, self).__init__()
109            self.mul = P.Mul()
110
111        def construct(self, x, y):
112            return self.mul(x, y)
113
114    x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
115    y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))
116
117    mul = Mul()
118    print(mul(x, y))
119    ```
120
121    ```text
122    [ 4. 10. 18.]
123    ```
124
125使用pip方式,在不同的环境安装MindSpore,可参考以下文档。
126
127- [Ascend环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_pip.md)
128- [GPU环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_pip.md)
129- [CPU环境使用pip方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_pip.md)
130
131### 源码编译方式安装
132
133使用源码编译方式,在不同的环境安装MindSpore,可参考以下文档。
134
135- [Ascend环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_ascend_install_source.md)
136- [GPU环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_gpu_install_source.md)
137- [CPU环境使用源码编译方式安装MindSpore](https://gitee.com/mindspore/docs/blob/master/install/mindspore_cpu_install_source.md)
138
139### Docker镜像
140
141MindSpore的Docker镜像托管在[Docker Hub](https://hub.docker.com/r/mindspore)上。
142目前容器化构建选项支持情况如下:
143
144| 硬件平台   | Docker镜像仓库                | 标签                       | 说明                                       |
145| :----- | :------------------------ | :----------------------- | :--------------------------------------- |
146| CPU    | `mindspore/mindspore-cpu` | `x.y.z`                  | 已经预安装MindSpore `x.y.z` CPU版本的生产环境。       |
147|        |                           | `devel`                  | 提供开发环境从源头构建MindSpore(`CPU`后端)。安装详情请参考<https://www.mindspore.cn/install> 。 |
148|        |                           | `runtime`                | 提供运行时环境安装MindSpore二进制包(`CPU`后端)。         |
149| GPU    | `mindspore/mindspore-gpu` | `x.y.z`                  | 已经预安装MindSpore `x.y.z` GPU版本的生产环境。       |
150|        |                           | `devel`                  | 提供开发环境从源头构建MindSpore(`GPU CUDA10.1`后端)。安装详情请参考<https://www.mindspore.cn/install> 。 |
151|        |                           | `runtime`                | 提供运行时环境安装MindSpore二进制包(`GPU CUDA10.1`后端)。 |
152
153> **注意:** 不建议从源头构建GPU `devel` Docker镜像后直接安装whl包。我们强烈建议您在GPU `runtime` Docker镜像中传输并安装whl包。
154
155- CPU
156
157    对于`CPU`后端,可以直接使用以下命令获取并运行最新的稳定镜像:
158
159    ```bash
160    docker pull mindspore/mindspore-cpu:1.1.0
161    docker run -it mindspore/mindspore-cpu:1.1.0 /bin/bash
162    ```
163
164- GPU
165
166    对于`GPU`后端,请确保`nvidia-container-toolkit`已经提前安装,以下是`Ubuntu`用户安装指南:
167
168    ```bash
169    DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
170    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
171    curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
172
173    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
174    sudo systemctl restart docker
175    ```
176
177    编辑文件 daemon.json:
178
179    ```bash
180    $ vim /etc/docker/daemon.json
181    {
182        "runtimes": {
183            "nvidia": {
184                "path": "nvidia-container-runtime",
185                "runtimeArgs": []
186            }
187        }
188    }
189    ```
190
191    再次重启docker:
192
193    ```bash
194    sudo systemctl daemon-reload
195    sudo systemctl restart docker
196    ```
197
198    使用以下命令获取并运行最新的稳定镜像:
199
200    ```bash
201    docker pull mindspore/mindspore-gpu:1.1.0
202    docker run -it -v /dev/shm:/dev/shm --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.1.0 /bin/bash
203    ```
204
205    要测试Docker是否正常工作,请运行下面的Python代码并检查输出:
206
207    ```python
208    import numpy as np
209    import mindspore.context as context
210    from mindspore import Tensor
211    from mindspore.ops import functional as F
212
213    context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
214
215    x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
216    y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
217    print(F.tensor_add(x, y))
218    ```
219
220    ```text
221    [[[ 2.  2.  2.  2.],
222    [ 2.  2.  2.  2.],
223    [ 2.  2.  2.  2.]],
224
225    [[ 2.  2.  2.  2.],
226    [ 2.  2.  2.  2.],
227    [ 2.  2.  2.  2.]],
228
229    [[ 2.  2.  2.  2.],
230    [ 2.  2.  2.  2.],
231    [ 2.  2.  2.  2.]]]
232    ```
233
234如果您想了解更多关于MindSpore Docker镜像的构建过程,请查看[docker](https://gitee.com/mindspore/mindspore/blob/master/scripts/docker/README.md) repo了解详细信息。
235
236## 快速入门
237
238参考[快速入门](https://www.mindspore.cn/tutorials/zh-CN/master/beginner/quick_start.html)实现图片分类。
239
240## 文档
241
242有关安装指南、教程和API的更多详细信息,请参阅[用户文档](https://gitee.com/mindspore/docs)243
244## 社区
245
246### 治理
247
248查看MindSpore如何进行[开放治理](https://gitee.com/mindspore/community/blob/master/governance.md)249
250### 交流
251
252- [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) 开发者交流平台。
253- `#mindspore`IRC频道(仅用于会议记录)
254- 视频会议:待定
255- 邮件列表:<https://mailweb.mindspore.cn/postorius/lists>
256
257## 贡献
258
259欢迎参与贡献。更多详情,请参阅我们的[贡献者Wiki](https://gitee.com/mindspore/mindspore/blob/master/CONTRIBUTING.md)260
261## 分支维护策略
262
263MindSpore的版本分支有以下几种维护阶段:
264
265| **状态**       | **持续时间**    | **说明**                                          |
266|-------------|---------------|--------------------------------------------------|
267| Planning    | 1 - 3 months  | 特性规划。                     |
268| Development | 3 months      | 特性开发。                  |
269| Maintained  | 6 - 12 months | 允许所有问题修复的合入,并发布版本。 |
270| Unmaintained| 0 - 3 months  | 允许所有问题修复的合入,无专人维护,不再发布版本。                                                 |
271| End Of Life (EOL) |  N/A |  不再接受修改合入该分支。    |
272
273## 现有分支维护状态
274
275| **分支名** | **当前状态**  | **上线时间**          | **后续状态**                           | **EOL 日期**|
276|------------|--------------|----------------------|----------------------------------------|------------|
277| **r1.8**   | Maintained   | 2022-07-29           | Unmaintained <br> 2023-07-29 estimated |            |
278| **r1.7**   | Maintained   | 2022-04-29           | Unmaintained <br> 2023-04-29 estimated |            |
279| **r1.6**   | Maintained   | 2022-01-29           | Unmaintained <br> 2023-01-29 estimated |            |
280| **r1.5**   | Maintained   | 2021-10-15           | Unmaintained <br> 2022-10-15 estimated |            |
281| **r1.4**   | Maintained   | 2021-08-15           | Unmaintained <br> 2022-08-15 estimated |            |
282| **r1.3**   | End Of Life  | 2021-07-15           |                                        | 2022-07-15 |
283| **r1.2**   | End Of Life  | 2021-04-15           |                                        | 2022-04-29 |
284| **r1.1**   | End Of Life  | 2020-12-31           |                                        | 2021-09-30 |
285| **r1.0**   | End Of Life  | 2020-09-24           |                                        | 2021-07-30 |
286| **r0.7**   | End Of Life  | 2020-08-31           |                                        | 2021-02-28 |
287| **r0.6**   | End Of Life  | 2020-07-31           |                                        | 2020-12-30 |
288| **r0.5**   | End Of Life  | 2020-06-30           |                                        | 2021-06-30 |
289| **r0.3**   | End Of Life  | 2020-05-31           |                                        | 2020-09-30 |
290| **r0.2**   | End Of Life  | 2020-04-30           |                                        | 2020-08-31 |
291| **r0.1**   | End Of Life  | 2020-03-28           |                                        | 2020-06-30 |
292
293## 版本说明
294
295版本说明请参阅[RELEASE](https://gitee.com/mindspore/mindspore/blob/master/RELEASE.md)296
297## 许可证
298
299[Apache License 2.0](https://gitee.com/mindspore/mindspore/blob/master/LICENSE)
300
301
302---
303
304## OpenHarmony MindSpore系统组件
305
306Mindspore Lite,和MindIR构图接口已内置到OpenHarmony标准系统。
307
308如需了解MindSpore Lite推理框架,请详见[MindSpore Lite介绍](mindspore/lite/README_CN.md)。
309
310### OpenHarmony组件使用MindSpore Lite
311
312在组件BUILD.gn中加入如下依赖即可使用MindSpore Lite:
313
314```gn
315include_dirs = [
316    "//third_party/mindspore/mindspore-src/source/"
317]
318external_deps = ["mindspore:mindspore_lib"]
319```
320注意:`mindspore-src/`为构建时生成的源码目录,仅下载源代码时,此目录不存在!
321
322- 使用C++ API
323
324C++ API头文件存放在`include/api`目录中,使用如下方式包含:
325
326```C++
327#include "include/api/xxx.h"
328```
329
330C API头文件存放在`include/c_api`目录中,使用如下方式包含:
331
332```C
333#include "include/c_api/xxx.h"
334```
335### MindIR 构图接口
336MindIR是MindSpore Lite用于描述模型计算图的中间表达方式。
337Primitive 是一套基于flatbuffers的对模型进行序列化的工具,MindSpore Lite使用它存储图结构、算子、张量等信息。
338Lite Graph是MindSpore Lite用于描述模型中节点、张量、子图等信息的结构,可通过MindIR接口构建。
339
340#### 使用MindIR
341BUILD.gn中加入如下依赖即可使用MindIR 构图接口:
342```gn
343include_dirs = [
344    "//third_party/mindspore/mindspore-src/source/mindspore/lite/mindir/include"
345]
346external_deps = ["mindspore:mindir"]
347```
348
349MindIR C++ API接口存放目录为`third_party/mindspore/mindspore-src/source/mindspore/lite/mindir/include`。
350
351```
352├── include                     # 对外的所有头文件
353│   ├── mindir.h                # MindIR所有功能的头文件
354│   ├── mindir_lite_graph.h     # Lite Graph相关的头文件
355│   ├── mindir_primitive.h      # Primitive相关头文件
356│   ├── mindir_tensor.h         # Tensor相关头文件
357│   └── mindir_types.h          # 类型相关的头文件
358├── inner_headers               # 内部使用的头文件
359├── src                         # MindIR构图接口的源代码
360└── tests                       # 测试代码
361```
362
363### 编译MindSpore Lite
364
365以rk3568为例,单独编译mindspore lite动态库:
366
367```bash
368./build.sh --product-name rk3568 --target-cpu arm -T mindspore_lib --ccache
369```
370
371编译出的so文件位于`out/rk3568/thirdparty/mindspore/`目录。
372
373```
374libmindir.z.so  libmindspore-lite.huawei.so
375```
376
377