You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 11 kB

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. ![MindSpore Logo](docs/MindSpore-logo.png "MindSpore logo")
  2. ============================================================
  3. [查看中文](./README_CN.md)
  4. - [What Is MindSpore](#what-is-mindspore)
  5. - [Automatic Differentiation](#automatic-differentiation)
  6. - [Automatic Parallel](#automatic-parallel)
  7. - [Installation](#installation)
  8. - [Binaries](#binaries)
  9. - [From Source](#from-source)
  10. - [Docker Image](#docker-image)
  11. - [Quickstart](#quickstart)
  12. - [Docs](#docs)
  13. - [Community](#community)
  14. - [Governance](#governance)
  15. - [Communication](#communication)
  16. - [Contributing](#contributing)
  17. - [Release Notes](#release-notes)
  18. - [License](#license)
  19. ## What Is MindSpore
  20. MindSpore is a new open source deep learning training/inference framework that
  21. could be used for mobile, edge and cloud scenarios. MindSpore is designed to
  22. provide development experience with friendly design and efficient execution for
  23. the data scientists and algorithmic engineers, native support for Ascend AI
  24. processor, and software hardware co-optimization. At the meantime MindSpore as
  25. a global AI open source community, aims to further advance the development and
  26. enrichment of the AI software/hardware application ecosystem.
  27. <img src="docs/MindSpore-architecture.png" alt="MindSpore Architecture" width="600"/>
  28. For more details please check out our [Architecture Guide](https://www.mindspore.cn/doc/note/en/master/design/mindspore/architecture.html).
  29. ### Automatic Differentiation
  30. There are currently three automatic differentiation techniques in mainstream deep learning frameworks:
  31. - **Conversion based on static compute graph**: Convert the network into a static data flow graph at compile time, then turn the chain rule into a data flow graph to implement automatic differentiation.
  32. - **Conversion based on dynamic compute graph**: 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.
  33. - **Conversion based on source code**: 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.
  34. TensorFlow adopted static calculation diagrams in the early days, whereas PyTorch used dynamic calculation diagrams. Static maps can utilize static compilation technology to optimize network performance, however, building a network or debugging it is very complicated. The use of dynamic graphics is very convenient, but it is difficult to achieve extreme optimization in performance.
  35. But MindSpore finds another way, automatic differentiation based on source code conversion. 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.
  36. <img src="docs/Automatic-differentiation.png" alt="Automatic Differentiation" width="600"/>
  37. The 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.
  38. ### Automatic Parallel
  39. The 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.
  40. <img src="docs/Automatic-parallel.png" alt="Automatic Parallel" width="600"/>
  41. At present, MindSpore uses a fine-grained parallel strategy of splitting operators, that is, each operator in the figure is splitted 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.
  42. ## Installation
  43. ### Binaries
  44. MindSpore offers build options across multiple backends:
  45. | Hardware Platform | Operating System | Status |
  46. | :---------------- | :--------------- | :----- |
  47. | Ascend910 | Ubuntu-x86 | ✔️ |
  48. | | Ubuntu-aarch64 | ✔️ |
  49. | | EulerOS-x86 | ✔️ |
  50. | | EulerOS-aarch64 | ✔️ |
  51. | | CentOS-x86 | ✔️ |
  52. | | CentOS-aarch64 | ✔️ |
  53. | GPU CUDA 10.1 | Ubuntu-x86 | ✔️ |
  54. | CPU | Ubuntu-x86 | ✔️ |
  55. | | Ubuntu-aarch64 | ✔️ |
  56. | | Windows-x86 | ✔️ |
  57. For installation using `pip`, take `CPU` and `Ubuntu-x86` build version as an example:
  58. 1. Download whl from [MindSpore download page](https://www.mindspore.cn/versions/en), and install the package.
  59. ```
  60. pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.0.0/MindSpore/cpu/ubuntu_x86/mindspore-1.0.0-cp37-cp37m-linux_x86_64.whl
  61. ```
  62. 2. Run the following command to verify the install.
  63. ```python
  64. import numpy as np
  65. import mindspore.context as context
  66. import mindspore.nn as nn
  67. from mindspore import Tensor
  68. from mindspore.ops import operations as P
  69. context.set_context(mode=context.GRAPH_MODE, device_target="CPU")
  70. class Mul(nn.Cell):
  71. def __init__(self):
  72. super(Mul, self).__init__()
  73. self.mul = P.Mul()
  74. def construct(self, x, y):
  75. return self.mul(x, y)
  76. x = Tensor(np.array([1.0, 2.0, 3.0]).astype(np.float32))
  77. y = Tensor(np.array([4.0, 5.0, 6.0]).astype(np.float32))
  78. mul = Mul()
  79. print(mul(x, y))
  80. ```
  81. ```
  82. [ 4. 10. 18.]
  83. ```
  84. ### From Source
  85. [Install MindSpore](https://www.mindspore.cn/install/en).
  86. ### Docker Image
  87. MindSpore docker image is hosted on [Docker Hub](https://hub.docker.com/r/mindspore),
  88. currently the containerized build options are supported as follows:
  89. | Hardware Platform | Docker Image Repository | Tag | Description |
  90. | :---------------- | :---------------------- | :-- | :---------- |
  91. | CPU | `mindspore/mindspore-cpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` CPU release. |
  92. | | | `devel` | Development environment provided to build MindSpore (with `CPU` backend) from the source, refer to https://www.mindspore.cn/install/en for installation details. |
  93. | | | `runtime` | Runtime environment provided to install MindSpore binary package with `CPU` backend. |
  94. | GPU | `mindspore/mindspore-gpu` | `x.y.z` | Production environment with pre-installed MindSpore `x.y.z` GPU release. |
  95. | | | `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. |
  96. | | | `runtime` | Runtime environment provided to install MindSpore binary package with `GPU CUDA10.1` backend. |
  97. | Ascend | <center>&mdash;</center> | <center>&mdash;</center> | Coming soon. |
  98. > **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.
  99. * CPU
  100. For `CPU` backend, you can directly pull and run the latest stable image using the below command:
  101. ```
  102. docker pull mindspore/mindspore-cpu:1.0.0
  103. docker run -it mindspore/mindspore-cpu:1.0.0 /bin/bash
  104. ```
  105. * GPU
  106. For `GPU` backend, please make sure the `nvidia-container-toolkit` has been installed in advance, here are some install guidelines for `Ubuntu` users:
  107. ```
  108. DISTRIBUTION=$(. /etc/os-release; echo $ID$VERSION_ID)
  109. curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
  110. curl -s -L https://nvidia.github.io/nvidia-docker/$DISTRIBUTION/nvidia-docker.list | tee /etc/apt/sources.list.d/nvidia-docker.list
  111. sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit nvidia-docker2
  112. sudo systemctl restart docker
  113. ```
  114. Then edit the file daemon.json:
  115. ```
  116. $ vim /etc/docker/daemon.json
  117. {
  118. "runtimes": {
  119. "nvidia": {
  120. "path": "nvidia-container-runtime",
  121. "runtimeArgs": []
  122. }
  123. }
  124. }
  125. ```
  126. Restart docker again:
  127. ```
  128. sudo systemctl daemon-reload
  129. sudo systemctl restart docker
  130. ```
  131. Then you can pull and run the latest stable image using the below command:
  132. ```
  133. docker pull mindspore/mindspore-gpu:1.0.0
  134. docker run -it --runtime=nvidia --privileged=true mindspore/mindspore-gpu:1.0.0 /bin/bash
  135. ```
  136. To test if the docker image works, please execute the python code below and check the output:
  137. ```python
  138. import numpy as np
  139. import mindspore.context as context
  140. from mindspore import Tensor
  141. from mindspore.ops import functional as F
  142. context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU")
  143. x = Tensor(np.ones([1,3,3,4]).astype(np.float32))
  144. y = Tensor(np.ones([1,3,3,4]).astype(np.float32))
  145. print(F.tensor_add(x, y))
  146. ```
  147. ```
  148. [[[ 2. 2. 2. 2.],
  149. [ 2. 2. 2. 2.],
  150. [ 2. 2. 2. 2.]],
  151. [[ 2. 2. 2. 2.],
  152. [ 2. 2. 2. 2.],
  153. [ 2. 2. 2. 2.]],
  154. [[ 2. 2. 2. 2.],
  155. [ 2. 2. 2. 2.],
  156. [ 2. 2. 2. 2.]]]
  157. ```
  158. If you want to learn more about the building process of MindSpore docker images,
  159. please check out [docker](docker/README.md) repo for the details.
  160. ## Quickstart
  161. See the [Quick Start](https://www.mindspore.cn/tutorial/training/en/master/quick_start/quick_start.html)
  162. to implement the image classification.
  163. ## Docs
  164. More details about installation guide, tutorials and APIs, please see the
  165. [User Documentation](https://gitee.com/mindspore/docs).
  166. ## Community
  167. ### Governance
  168. Check out how MindSpore Open Governance [works](https://gitee.com/mindspore/community/blob/master/governance.md).
  169. ### Communication
  170. - [MindSpore Slack](https://join.slack.com/t/mindspore/shared_invite/zt-dgk65rli-3ex4xvS4wHX7UDmsQmfu8w) - Communication platform for developers.
  171. - IRC channel at `#mindspore` (only for meeting minutes logging purpose)
  172. - Video Conferencing: TBD
  173. - Mailing-list: <https://mailweb.mindspore.cn/postorius/lists>
  174. ## Contributing
  175. Welcome contributions. See our [Contributor Wiki](CONTRIBUTING.md) for
  176. more details.
  177. ## Release Notes
  178. The release notes, see our [RELEASE](RELEASE.md).
  179. ## License
  180. [Apache License 2.0](LICENSE)