当前位置:网站首页>Huawei Shengsi mindspire detailed tutorial
Huawei Shengsi mindspire detailed tutorial
2022-07-19 10:01:00 【Flower boy】
One 、 Related information
Two 、 Important note
- MindSpore Of Ascend Version and ascend-toolkit as well as driver There is a binding relationship between versions . Used on the shengteng platform MindSpore Depend on CANN, namely ascend-toolkit And driver Wait for the kit .
3、 ... and 、 Relevant concepts
3.1 ME
Mind Expression,MindSpore front end , It mainly completes the compilation tasks from user source code to calculation diagram 、 Control execution and context maintenance in training ( In non sinking mode configuration )、 Dynamic graph (PyNative Pattern ) etc. .
3.2 MindData
MindSpore Data frame , Provide data loading 、 enhance 、 Data set management and visualization .
3.3 MindInsight
MindSpore Visualization components , Visual scalar 、 Images 、 Calculation diagram and model hyperparametric information .
3.4 AIR
Ascend Intermediate Representation, similar ONNX, It is an open file format designed for machine learning defined by Huawei , Better fit Ascend AI processor , Commonly used in Ascend 310 Perform reasoning tasks on .
AIR Format only MindSpore Ascend 910 Exportable , only Ascend 310 Reasonable , Before reasoning, use Ascend CANN in atc Tool for model transformation , Reasoning does not depend on MindSpore, Only Ascend CANN software package .
Ascend 310 It is energy-efficient and highly integrated for edge scenes AI processor , Support for MindIR Format and AIR Format model for reasoning .
3.5 MindIR
MindIR Full name MindSpore IR, A kind of Functional expression based on graph representation IR, Defines extensible The graph structure as well as operator IR Express , Store MindSpore Infrastructure . it Eliminates model differences between different backend , Generally used to perform reasoning tasks across hardware platforms .MindSpore Through unification IR The logical structure of the network and the properties of the operator are defined , take MindIR The format of the model file is decoupled from the hardware platform , Realization One training, many deployments .
MindIR The format can be MindSpore CPU、GPU、Ascend 910 export , Can run in GPU、Ascend 910、Ascend 310 On , There is no need to manually perform model transformation before reasoning , Reasoning requires installation MindSpore, call MindSpore C++ API Reasoning .
characteristic
MindIR As MindSpore The first mock exam , At the same time, the network structure and weight parameter values are stored . At the same time, it supports deployment to the cloud Serving And the end side Lite The platform performs reasoning tasks .
The same MindIR The file supports the deployment of various hardware forms :
- Cloud Serving Deployment reasoning :MindSpore Training generation MindIR After the model file , It can be sent directly to MindSpore Serving load , Perform reasoning tasks , Without additional model transformation , Achieve Ascend、GPU、CPU And so on .
- End side Lite Reasoning deployment :MindIR It can be directly used for Lite Deployment use . At the same time, due to the end side lightweight demand , It provides model miniaturization and conversion functions , Support the original MindIR The model file is created by Protocol Buffers Format into FlatBuffers Format store , And lightweight network structure , To better meet the end side performance 、 Memory and other requirements .
Use scenarios
First use network definitions and Checkpoint File export MindIR Model file , Then perform reasoning tasks according to different needs .
- stay Ascend 310 Perform reasoning tasks on
- be based on MindSpore Serving Deploy inference Services
- End to side reasoning .
3.6 MindRecord
MindSpore A data format defined , Is an execution read 、 write in 、 Search and transform MindSpore Module of format data set .
3.7 MindSpore Lite
A lightweight deep neural network reasoning engine , Provided will be MindSpore The trained model has the function of reasoning on the end side .
3.8 PyNative Mode
MindSpore Dynamic patterns of patterns , Each operator in the neural network is issued and executed one by one , It is convenient for users to write and debug neural network models .
3.9 Graph Mode
MindSpore Static graph mode , Compile the neural network model into a whole picture , Then issue to execute , High performance .
3.10 MindArmour
MindSpore Security module , Through differential privacy 、 Antagonistic attack and defense and other technical means , Improve the confidentiality of the model 、 Integrity and availability , Prevent attackers from maliciously modifying the model or cracking the internals of the model , Steal the parameters of the model .
Four 、 Related introduction
- MindSpore Back end support includes Ascend、GPU、CPU.
5、 ... and 、 Key tutorials
5.1 Installation plan (Windows)
MindStudio It can be installed separately Windows On . In the installation MindStudio Before you need stay Linux Install and deploy on the server Ascend-cann-toolkit Development kit , After the Windows Installation on MindStudio, Pass after installation Configure remote connection The way to build MindStudio Where Windows The server and Ascend-cann-toolkit Where the development kit is located Linux Server connection , Realize the whole process development function .
take MindStudio Installed in the Windows On the server ,Windows The server is a local environment ,Linux The server is a remote environment .
5.2 Installation plan (Linux)
MindStudio and Ascend-cann-toolkit have access to Linux The terminal of the native desktop on the server gnome-terminal Installation , It can also be in Windows Pass on server SSH Log in to Linux Install the server . because MindStudio Is a GUI Program , So in Windows Pass on server SSH Log in to Linux When installing the server , Integration is needed X server Of SSH terminal ( such as MobaXterm, The tool version needs to be v20.2 And above ).
5.3 install MindStudio
Detailed installation tutorial , Please refer to the official website Installation guide .
5.4 install MindSpore
# Create a conda Virtual environment and activate
conda create -n mindsp python=3.7.5 -y
conda activate mindsp
# install MindSpore
pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp37-cp37m-win_amd64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
# Verify that the installation was successful
python -c "import mindspore;mindspore.run_check()"
Verify success
(mindsp-py37) D:\360Downloads\vision>python -c "import mindspore;mindspore.run_check()"
MindSpore version: 1.7.0
The result of multiplication calculation is correct, MindSpore has been installed successfully!
[[email protected] mindspore-lenet-demo]$ python3 -c "import mindspore;mindspore.run_check()"
[WARNING] ME(1564:281472980111376,MainProcess):2022-07-04-16:35:16.111.95 [mindspore/run_check/_check_version.py:267] Using custom Ascend 910 AI software package path, package version checking is skipped, please make sure Ascend 910 AI software package version is supported, you can reference to the installation guidelines https://www.mindspore.cn/install
[WARNING] ME(1564:281472980111376,MainProcess):2022-07-04-16:35:16.179.332 [mindspore/run_check/_check_version.py:368] Can not find driver so(need by mindspore-ascend), please check if you have set env LD_LIBRARY_PATH, you can reference to the installation guidelines https://www.mindspore.cn/install
MindSpore version: 1.5.0
The result of multiplication calculation is correct, MindSpore has been installed successfully!
5.5 MindStudio To configure SSH
5.6 install MindSpore Vision
Source code installation
# Create a conda Virtual environment and activate
conda create -n mindvision python=3.7.5 -y
conda activate mindvision
# git clone MindSpore Vision Warehouse
git clone https://gitee.com/mindspore/vision.git
cd vision
# Source code installation
python setup.py install
# Verify that the installation was successful
python ./examples/classification/lenet/lenet_mnist_infer.py --data_url ./tests/st/classification/dataset/mnist/mnist.jpg --pretrained True --device_target CPU
Verify success
[WARNING] ME(25912:24800,MainProcess):2022-06-22-09:11:35.362.873 [mindspore\dataset\core\config.py:646] For Windows and MacOS we forbid shared mem function temporarily.
494592B [00:00, 1997626.51B/s]
{
4: 'four'}
pip install
pip install mindvision
6、 ... and 、 Quick start : Handwritten digit recognition
Follow the tutorial on the official website : Quick start : Handwritten digit recognition , Please refer to FAQ.
Mindspore:r1.7
MindSpore Vision:0.1.0
7、 ... and 、 model training
Follow the tutorial on the official website : model training , Please refer to FAQ.
8、 ... and 、 stay ModelArts notebook Medium training
[[email protected] mindspore-lenet-demo]$ python3 lenet_demo.py
[WARNING] ME(842:281473601032208,MainProcess):2022-07-04-16:27:03.476.263 [mindspore/run_check/_check_version.py:267] Using custom Ascend 910 AI software package path, package version checking is skipped, please make sure Ascend 910 AI software package version is supported, you can reference to the installation guidelines https://www.mindspore.cn/install
[WARNING] ME(842:281473601032208,MainProcess):2022-07-04-16:27:03.980.652 [mindspore/run_check/_check_version.py:368] Can not find driver so(need by mindspore-ascend), please check if you have set env LD_LIBRARY_PATH, you can reference to the installation guidelines https://www.mindspore.cn/install
[WARNING] ME(842:281473601032208,MainProcess):2022-07-04-16:27:11.532.279 [mindspore/dataset/core/config.py:464] The shared memory is on, multiprocessing performance will be improved. Note: the required shared memory can't exceeds 80% of the available shared memory. You can reduce max_rowsize or reduce num_parallel_workers to reduce shared memory usage. [WARNING] ME(842:281473601032208,MainProcess):2022-07-04-16:27:16.404.060 [mindspore/dataset/core/config.py:464] The shared memory is on, multiprocessing performance will be improved. Note: the required shared memory can't exceeds 80% of the available shared memory. You can reduce max_rowsize or reduce num_parallel_workers to reduce shared memory usage.
[WARNING] SESSION(842,fffe827fc1e0,python3):2022-07-04-16:27:28.599.092 [mindspore/ccsrc/backend/session/ascend_session.cc:1806] SelectKernel] There are 9 node/nodes used reduce precision to selected the kernel!
Epoch:[ 0/ 10], step:[ 1875/ 1875], loss:[0.138/0.138], time:27793.110 ms, lr:0.01000
Epoch time: 32266.532 ms, per step time: 17.209 ms, avg loss: 0.138
Epoch:[ 1/ 10], step:[ 1875/ 1875], loss:[0.001/0.001], time:3550.877 ms, lr:0.01000
Epoch time: 3552.153 ms, per step time: 1.894 ms, avg loss: 0.001
Epoch:[ 2/ 10], step:[ 1875/ 1875], loss:[0.017/0.017], time:3824.274 ms, lr:0.01000
Epoch time: 3825.681 ms, per step time: 2.040 ms, avg loss: 0.017
Epoch:[ 3/ 10], step:[ 1875/ 1875], loss:[0.003/0.003], time:3692.203 ms, lr:0.01000
Epoch time: 3693.945 ms, per step time: 1.970 ms, avg loss: 0.003
Epoch:[ 4/ 10], step:[ 1875/ 1875], loss:[0.025/0.025], time:3885.926 ms, lr:0.01000
Epoch time: 3887.030 ms, per step time: 2.073 ms, avg loss: 0.025
Epoch:[ 5/ 10], step:[ 1875/ 1875], loss:[0.000/0.000], time:3726.956 ms, lr:0.01000
Epoch time: 3727.775 ms, per step time: 1.988 ms, avg loss: 0.000
Epoch:[ 6/ 10], step:[ 1875/ 1875], loss:[0.042/0.042], time:3601.407 ms, lr:0.01000
Epoch time: 3602.245 ms, per step time: 1.921 ms, avg loss: 0.042
Epoch:[ 7/ 10], step:[ 1875/ 1875], loss:[0.001/0.001], time:4478.034 ms, lr:0.01000
Epoch time: 4478.895 ms, per step time: 2.389 ms, avg loss: 0.001
Epoch:[ 8/ 10], step:[ 1875/ 1875], loss:[0.006/0.006], time:4465.447 ms, lr:0.01000
Epoch time: 4466.262 ms, per step time: 2.382 ms, avg loss: 0.006
Epoch:[ 9/ 10], step:[ 1875/ 1875], loss:[0.004/0.004], time:4313.395 ms, lr:0.01000
Epoch time: 4314.218 ms, per step time: 2.301 ms, avg loss: 0.004
[WARNING] SESSION(842,fffe827fc1e0,python3):2022-07-04-16:28:25.698.502 [mindspore/ccsrc/backend/session/ascend_session.cc:1806] SelectKernel] There are 4 node/nodes used reduce precision to selected the kernel!
{
'accuracy': 0.9895833333333334}
[WARNING] ME(842:281473601032208,MainProcess):2022-07-04-16:28:33.318.388 [mindspore/dataset/core/config.py:464] The shared memory is on, multiprocessing performance will be improved. Note: the required shared memory can't exceeds 80% of the available shared memory. You can reduce max_rowsize or reduce num_parallel_workers to reduce shared memory usage.
[WARNING] SESSION(842,fffe827fc1e0,python3):2022-07-04-16:29:17.098.612 [mindspore/ccsrc/backend/session/ascend_session.cc:1806] SelectKernel] There are 4 node/nodes used reduce precision to selected the kernel!
Predicted: "[1 1 8 2 1 0]", Actual: "[1 1 8 2 1 0]"
Nine 、FAQ
Q:ImportError: cannot import name ‘Mnist’ from ‘mindvision.dataset’
Traceback (most recent call last):
File "D:/MyDocuments/PyProjects/pydemo/lenet_demo.py", line 8, in <module>
from mindvision.dataset import Mnist
ImportError: cannot import name 'Mnist' from 'mindvision.dataset' (D:\360Downloads\anaconda3\envs\mindsp-py37\lib\site-packages\mindvision-0.1.0-py3.7.egg\mindvision\dataset\__init__.py)
The reason for the error :
Guide Package error
from mindvision.dataset import Mnist
Change it to
from mindvision.classification.dataset import Mnist

边栏推荐
- 卟啉包裹型金属有机框架材料[email protected]|[email protected]<
- 【OpenCV 例程200篇】233. 区域特征之矩不变量
- 在线教育知识付费网站源码系统+直播+小程序,安装教程
- 浏览器的故事
- [C language] Pointer exercise 2 - real written test questions and analysis
- R language ggplot2 visual faceting: ggplot2 visualizes facets and removes the border lines between facets and the gap between facets (remove spacing between panels)
- 自己创建的模块 使用cmd打开报 ModuleNotFoundError: No module named 解决方案
- [C language] string, escape character and comment
- node+express搭建服务器环境
- 2022-07-16: what is the output of the following go language code? A:[]; B:[5]; C:[5 0 0 0 0]; D:[0 0 0 0 0]。 package main imp
猜你喜欢
![[C language] string, escape character and comment](/img/c5/6cfea937ea1568cedb8fad3c61e70a.png)
[C language] string, escape character and comment

ES6中的let、const、var

第4章-一阶多智体系统一致性 -> 领航跟随系统一致性

pfSense配置Tailscal站点到站点连接

Build a server environment with node+express

Week 1: introduction to deep learning and foundation of pytorch

Chapter XI queue of STL

华为昇思MindSpore详细教程

565. Array nesting / Sword finger offer II 001 Integer division

Among China's top ten national snacks, it is actually the first
随机推荐
Clwy permission management (III) -- user group module
氨基的金属-有机骨架材料Fe-MOF,Fe-MIL-88NH2|Zr基金属-有机骨架催化剂(Pt-UiO-66)|齐岳生物
Part I - Fundamentals of C language_ 2. Data type
TLS四次握手
Rhcsa the next day 7.15
第1周学习:深度学习入门和pytorch基础
对文本实现分词以及绘制词云
自己创建的模块 使用cmd打开报 ModuleNotFoundError: No module named 解决方案
Database overview
[动态规划]DP27 跳跃游戏(二)-中等
D. Mark and Lightbulbs
【C语言】浅涉选择、循环语句、函数及数组
2022-07-16: what is the output of the following go language code? A:[]; B:[5]; C:[5 0 0 0 0]; D:[0 0 0 0 0]。 package main imp
[C language] a brief introduction to the first C language program and data type
硫化镉负载MIL-125(Ti)|链霉亲和素(SA)-锆基卟啉MOF复合材料([email protected])|壳核结构
数据库概述
TLS four handshakes
齐岳供应负载亚甲基蓝的CuMOF纳米晶|原位生长在泡沫镍上FeMOF纳米片|氧化物纳米线/ZIF系MOFs糖葫芦状复合材料
npm使用
es索引、类型(mapping)、文档、ik分词器
