From 9b40a1122ef83456a0912ed12e79c529de1911a9 Mon Sep 17 00:00:00 2001 From: liuxiao78 Date: Sat, 29 Aug 2020 17:05:33 +0800 Subject: [PATCH] fix compile.md --- .../source_en/{deploy.md => compile.md} | 8 +- lite/tutorials/source_zh_cn/compile.md | 228 ++++++++++++++++++ lite/tutorials/source_zh_cn/deploy.md | 188 --------------- 3 files changed, 232 insertions(+), 192 deletions(-) rename lite/tutorials/source_en/{deploy.md => compile.md} (96%) create mode 100644 lite/tutorials/source_zh_cn/compile.md delete mode 100644 lite/tutorials/source_zh_cn/deploy.md diff --git a/lite/tutorials/source_en/deploy.md b/lite/tutorials/source_en/compile.md similarity index 96% rename from lite/tutorials/source_en/deploy.md rename to lite/tutorials/source_en/compile.md index 4429c78551..9f7ae53c96 100644 --- a/lite/tutorials/source_en/deploy.md +++ b/lite/tutorials/source_en/compile.md @@ -1,8 +1,8 @@ -# Deploy +# Compile -- [Deployment](#deployment) +- [compilation](#compilation) - [Environment Requirements](#environment-requirements) - [Compilation Options](#compilation-options) - [Output Description](#output-description) @@ -10,7 +10,7 @@ - + This document describes how to quickly install MindSpore Lite on the Ubuntu system. @@ -57,7 +57,7 @@ After the compilation is complete, go to the `mindspore/output` directory of the > version: version of the output, consistent with that of the MindSpore. > -> function: function of the output. `convert` indicates the output of the conversion tool and `runtime` indicates the output of the inference framework. +> function: function of the output. `converter` indicates the output of the conversion tool and `runtime` indicates the output of the inference framework. > > OS: OS on which the output will be deployed. diff --git a/lite/tutorials/source_zh_cn/compile.md b/lite/tutorials/source_zh_cn/compile.md new file mode 100644 index 0000000000..c558bb6e08 --- /dev/null +++ b/lite/tutorials/source_zh_cn/compile.md @@ -0,0 +1,228 @@ +# 编译 + + + +- [编译](#编译) + - [Linux环境编译](#linux环境编译) + - [环境要求](#环境要求) + - [编译选项](#编译选项) + - [编译示例](#编译示例) + - [编译输出](#编译输出) + - [模型转换工具converter目录结构说明](#模型转换工具converter目录结构说明) + - [模型推理框架runtime及其他工具目录结构说明](#模型推理框架runtime及其他工具目录结构说明) + - [Windows环境编译](#windows环境编译) + - [环境要求](#环境要求-1) + - [编译选项](#编译选项-1) + - [编译示例](#编译示例-1) + + + + + + +本章节介绍如何在Ubuntu系统上快速编译出MindSpore Lite,其包含的模块如下: + +| 模块 | 支持平台 | 说明 | +| --- | ---- | ---- | +| converter | Linux、Windows | 模型转换工具 | +| runtime | Linux、Android | 模型推理框架 | +| benchmark | Linux、Android | 基准测试工具 | +| time_profiler | Linux、Android | 性能分析工具 | + +## Linux环境编译 + +### 环境要求 + +- 系统环境:Linux x86_64,推荐使用Ubuntu 18.04.02LTS + +- runtime、benchmark、time_profiler编译依赖 + - [CMake](https://cmake.org/download/) >= 3.14.1 + - [GCC](https://gcc.gnu.org/releases.html) >= 7.3.0 + - [Android_NDK](https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip) >= r20 + - [Git](https://git-scm.com/downloads) >= 2.28.0 + +- converter编译依赖 + - [CMake](https://cmake.org/download/) >= 3.14.1 + - [GCC](https://gcc.gnu.org/releases.html) >= 7.3.0 + - [Android_NDK](https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip) >= r20 + - [Git](https://git-scm.com/downloads) >= 2.28.0 + - [Autoconf](http://ftp.gnu.org/gnu/autoconf/) >= 2.69 + - [Libtool](https://www.gnu.org/software/libtool/) >= 2.4.6 + - [LibreSSL](http://www.libressl.org/) >= 3.1.3 + - [Automake](https://www.gnu.org/software/automake/) >= 1.11.6 + - [Libevent](https://libevent.org) >= 2.0 + - [M4](https://www.gnu.org/software/m4/m4.html) >= 1.4.18 + - [OpenSSL](https://www.openssl.org/) >= 1.1.1 + +> 编译脚本中会执行`git clone`获取第三方依赖库的代码,请提前确保git的网络设置正确可用。 + +### 编译选项 + +MindSpore Lite提供编译脚本`build.sh`用于一键式编译,位于MindSpore根目录下,该脚本可用于MindSpore训练及推理的编译。下面对MindSpore Lite的编译选项进行说明。 + +| 选项 | 参数说明 | 取值范围 | 是否必选 | +| -------- | ----- | ---- | ---- | +| **-I** | **选择适用架构,编译MindSpore Lite此选项必选** | **arm64、arm32、x86_64** | **是** | +| -d | 设置该参数,则编译Debug版本,否则编译Release版本 | 无 | 否 | +| -i | 设置该参数,则进行增量编译,否则进行全量编译 | 无 | 否 | +| -j[n] | 设定编译时所用的线程数,否则默认设定为8线程 | Integer | 否 | +| -e | 选择除CPU之外的其他内置算子类型,仅在ARM架构下适用,当前仅支持GPU | gpu | 否 | +| -h | 显示编译帮助信息 | 无 | 否 | + +> 在`-I`参数变动时,如`-I x86_64`变为`-I arm64`,添加`-i`参数进行增量编译不生效。 + +### 编译示例 + +首先,在进行编译之前,需从MindSpore代码仓下载源码。 + +```bash +git clone https://gitee.com/mindspore/mindspore.git +``` + +然后,在源码根目录下执行如下命令,可编译不同版本的MindSpore Lite。 + +- 编译x86_64架构Debug版本。 + ```bash + bash build.sh -I x86_64 -d + ``` + +- 编译x86_64架构Release版本,同时设定线程数。 + ```bash + bash build.sh -I x86_64 -j32 + ``` + +- 增量编译ARM64架构Release版本,同时设定线程数。 + ```bash + bash build.sh -I arm64 -i -j32 + ``` + +- 编译ARM64架构Release版本,同时编译内置的GPU算子。 + ```bash + bash build.sh -I arm64 -e gpu + ``` + +### 编译输出 + +编译完成后,进入`mindspore/output/`目录,可查看编译后生成的文件。文件分为两部分: +- `mindspore-lite-{version}-converter-{os}.tar.gz`:包含模型转换工具converter。 +- `mindspore-lite-{version}-runtime-{os}-{device}.tar.gz`:包含模型推理框架runtime、基准测试工具benchmark和性能分析工具time_profiler。 + +> version:输出件版本号,与所编译的分支代码对应的版本一致。 +> +> device:当前分为cpu(内置CPU算子)和gpu(内置CPU和GPU算子)。 +> +> os:输出件应部署的操作系统。 + +执行解压缩命令,获取编译后的输出件: + +```bash +tar -xvf mindspore-lite-{version}-converter-{os}.tar.gz +tar -xvf mindspore-lite-{version}-runtime-{os}-{device}.tar.gz +``` + +#### 模型转换工具converter目录结构说明 + +转换工具仅在`-I x86_64`编译选项下获得,内容包括以下几部分: + +``` +| +├── mindspore-lite-{version}-converter-{os} +│ └── converter # 模型转换工具 +│ └── third_party # 第三方库头文件和库 +│ ├── protobuf # Protobuf的动态库 + +``` + +#### 模型推理框架runtime及其他工具目录结构说明 + +推理框架可在`-I x86_64`、`-I arm64`和`-I arm32`编译选项下获得,内容包括以下几部分: + +- 当编译选项为`-I x86_64`时: + ``` + | + ├── mindspore-lite-{version}-runtime-x86-cpu + │ └── benchmark # 基准测试工具 + │ └── lib # 推理框架动态库 + │ ├── libmindspore-lite.so # MindSpore Lite推理框架的动态库 + │ └── third_party # 第三方库头文件和库 + │ ├── flatbuffers # FlatBuffers头文件 + + ``` + +- 当编译选项为`-I arm64`时: + ``` + | + ├── mindspore-lite-{version}-runtime-arm64-cpu + │ └── benchmark # 基准测试工具 + │ └── lib # 推理框架动态库 + │ ├── libmindspore-lite.so # MindSpore Lite推理框架的动态库 + │ ├── liboptimize.so # MindSpore Lite算子性能优化库 + │ └── third_party # 第三方库头文件和库 + │ ├── flatbuffers # FlatBuffers头文件 + │ └── include # 推理框架头文件 + │ └── time_profiler # 模型网络层耗时分析工具 + + ``` + +- 当编译选项为`-I arm32`时: + ``` + | + ├── mindspore-lite-{version}-runtime-arm64-cpu + │ └── benchmark # 基准测试工具 + │ └── lib # 推理框架动态库 + │ ├── libmindspore-lite.so # MindSpore Lite推理框架的动态库 + │ └── third_party # 第三方库头文件和库 + │ ├── flatbuffers # FlatBuffers头文件 + │ └── include # 推理框架头文件 + │ └── time_profiler # 模型网络层耗时分析工具 + + ``` + +> 1. `liboptimize.so`仅在runtime-arm64的输出包中存在,仅在ARMv8.2和支持fp16特性的CPU上使用。 +> 2. 编译ARM64默认可获得arm64-cpu的推理框架输出件,若添加`-e gpu`则获得arm64-gpu的推理框架输出件,此时包名为`mindspore-lite-{version}-runtime-arm64-gpu.tar.gz`,编译ARM32同理。 +> 3. 运行converter、benchmark或time_profiler目录下的工具前,都需配置环境变量,将MindSpore Lite和Protobuf的动态库所在的路径配置到系统搜索动态库的路径中。以0.7.0-beta版本下编译CPU为例:配置converter:`export LD_LIBRARY_PATH=./mindspore-lite-0.7.0-converter-ubuntu/third_party/protobuf/lib`;配置benchmark和time_profiler:`export LD_LIBRARY_PATH=./mindspore-lite-0.7.0-runtime-x86-cpu/lib` + + +## Windows环境编译 + +### 环境要求 + +- 支持的编译环境为:Windows 10,64位。 + +- 编译依赖 + - [CMake](https://cmake.org/download/) >= 3.14.1 + - [MinGW GCC](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z/download) >= 7.3.0 + - [Python](https://www.python.org/) >= 3.7.5 + - [Git](https://git-scm.com/downloads) >= 2.28.0 + +> 编译脚本中会执行`git clone`获取第三方依赖库的代码,请提前确保git的网络设置正确可用。 + +### 编译选项 + +MindSpore Lite的编译选项如下。 + +| 参数 | 参数说明 | 是否必选 | +| -------- | ----- | ---- | +| **lite** | **设置该参数,则对Mindspore Lite工程进行编译** | **是** | +| [n] | 设定编译时所用的线程数,否则默认设定为6线程 | 否 | + +### 编译示例 + +首先,使用git工具从MindSpore代码仓下载源码。 + +```bash +git clone https://gitee.com/mindspore/mindspore.git +``` + +然后,使用cmd工具在源码根目录下,执行如下命令即可编译MindSpore Lite。 + +- 以默认线程数(6线程)编译Windows版本。 + ```bash + call build.bat lite + ``` +- 以指定线程数8编译Windows版本。 + ```bash + call build.bat lite 8 + ``` + +编译完成之后,进入`mindspore/output/`目录,解压后即可获取输出件`mindspore-lite-0.7.0-converter-win-cpu.zip`,其中含有转换工具可执行文件。 diff --git a/lite/tutorials/source_zh_cn/deploy.md b/lite/tutorials/source_zh_cn/deploy.md deleted file mode 100644 index 28748fbca5..0000000000 --- a/lite/tutorials/source_zh_cn/deploy.md +++ /dev/null @@ -1,188 +0,0 @@ -# 部署 - - - -- [部署](#部署) - - [Linux环境部署](#linux环境部署) - - [环境要求](#环境要求) - - [编译选项](#编译选项) - - [输出件说明](#输出件说明) - - [编译示例](#编译示例) - - [Windows环境部署](#windows环境部署) - - [环境要求](#环境要求-1) - - [编译选项](#编译选项-1) - - [输出件说明](#输出件说明-1) - - [编译示例](#编译示例-1) - - - - - -本文档介绍如何在Ubuntu和Windows系统上快速安装MindSpore Lite。 - -## Linux环境部署 - -### 环境要求 - -- 编译环境仅支持x86_64版本的Linux:推荐使用Ubuntu 18.04.02LTS - -- 编译依赖(基本项) - - [CMake](https://cmake.org/download/) >= 3.14.1 - - [GCC](https://gcc.gnu.org/releases.html) >= 7.3.0 - - [Android_NDK r20b](https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip) - - > - 仅在编译ARM版本时需要安装`Android_NDK`,编译x86_64版本可跳过此项。 - > - 如果安装并使用`Android_NDK`,需配置环境变量,命令参考:`export ANDROID_NDK={$NDK_PATH}/android-ndk-r20b`。 - -- 编译依赖(MindSpore Lite模型转换工具所需附加项,仅编译x86_64版本时需要) - - [Autoconf](http://ftp.gnu.org/gnu/autoconf/) >= 2.69 - - [Libtool](https://www.gnu.org/software/libtool/) >= 2.4.6 - - [LibreSSL](http://www.libressl.org/) >= 3.1.3 - - [Automake](https://www.gnu.org/software/automake/) >= 1.11.6 - - [Libevent](https://libevent.org) >= 2.0 - - [M4](https://www.gnu.org/software/m4/m4.html) >= 1.4.18 - - [OpenSSL](https://www.openssl.org/) >= 1.1.1 - - -### 编译选项 - -MindSpore Lite提供多种编译方式,用户可根据需要选择不同的编译选项。 - -| 参数 | 参数说明 | 取值范围 | 是否必选 | -| -------- | ----- | ---- | ---- | -| -d | 设置该参数,则编译Debug版本,否则编译Release版本 | - | 否 | -| -i | 设置该参数,则进行增量编译,否则进行全量编译 | - | 否 | -| -j[n] | 设定编译时所用的线程数,否则默认设定为8线程 | - | 否 | -| -I | 选择适用架构 | arm64、arm32、x86_64 | 是 | -| -e | 在ARM架构下,选择后端算子,设置`gpu`参数,会同时编译框架内置的GPU算子 | gpu | 否 | -| -h | 设置该参数,显示编译帮助信息 | - | 否 | - -> 在`-I`参数变动时,即切换适用架构时,无法使用`-i`参数进行增量编译。 - -### 输出件说明 - -编译完成后,进入源码的`mindspore/output`目录,可查看编译后生成的文件,命名为`mindspore-lite-{version}-{function}-{OS}.tar.gz`。解压后,即可获得编译后的工具包,名称为`mindspore-lite-{version}-{function}-{OS}`。 - -> version:输出件版本,与所编译的MindSpore版本一致。 -> -> function:输出件功能,`convert`表示为转换工具的输出件,`runtime`表示为推理框架的输出件。 -> -> OS:输出件应部署的操作系统。 - -```bash -tar -xvf mindspore-lite-{version}-{function}-{OS}.tar.gz -``` -编译x86可获得转换工具`converter`与推理框架`runtime`功能的输出件,编译ARM仅能获得推理框架`runtime`。 - -输出件中包含以下几类子项,功能不同所含内容也会有所区别。 - -> 编译ARM64默认可获得`arm64-cpu`的推理框架输出件,若添加`-e gpu`则获得`arm64-gpu`的推理框架输出件,编译ARM32同理。 - -| 目录 | 说明 | converter | runtime | -| --- | --- | --- | --- | -| include | 推理框架头文件 | 无 | 有 | -| lib | 推理框架动态库 | 无 | 有 | -| benchmark | 基准测试工具 | 无 | 有 | -| time_profiler | 模型网络层耗时分析工具 | 无 | 有 | -| converter | 模型转换工具 | 有 | 无 | -| third_party | 第三方库头文件和库 | 有 | 有 | - -以0.7.0-beta版本,CPU编译为例,不同包名下,`third party`与`lib`的内容不同: - -- `mindspore-lite-0.7.0-converter-ubuntu`:`third party`包含`protobuf`(Protobuf的动态库)。 -- `mindspore-lite-0.7.0-runtime-x86-cpu`:`third party`包含`flatbuffers`(FlatBuffers头文件),`lib`包含`libmindspore-lite.so`(MindSpore Lite推理框架的动态库)。 -- `mindspore-lite-0.7.0-runtime-arm64-cpu`:`third party`包含`flatbuffers`(FlatBuffers头文件),`lib`包含`libmindspore-lite.so`(MindSpore Lite推理框架的动态库)和`liboptimize.so`(MindSpore Lite算子性能优化库)。 - -> `liboptimize.so`仅在runtime-arm64的输出包中存在,仅在armv8.2和支持fp16特性的CPU上使用。 - -> 运行converter、benchmark或time_profiler目录下的工具前,都需配置环境变量,将MindSpore Lite和Protobuf的动态库所在的路径配置到系统搜索动态库的路径中。以0.7.0-beta版本为例:`export LD_LIBRARY_PATH=./mindspore-lite-0.7.0/lib:./mindspore-lite-0.7.0/third_party/protobuf/lib:${LD_LIBRARY_PATH}`。 - -### 编译示例 - -首先,从MindSpore代码仓下载源码。 - -```bash -git clone https://gitee.com/mindspore/mindspore.git -``` - -然后,在源码根目录下,执行如下命令,可编译不同版本的MindSpore Lite。 - -- 编译x86_64架构Debug版本。 - ```bash - bash build.sh -I x86_64 -d - ``` - -- 编译x86_64架构Release版本,同时设定线程数。 - ```bash - bash build.sh -I x86_64 -j32 - ``` - -- 增量编译ARM64架构Release版本,同时设定线程数。 - ```bash - bash build.sh -I arm64 -i -j32 - ``` - -- 编译ARM64架构Release版本,同时编译内置的GPU算子。 - ```bash - bash build.sh -I arm64 -e gpu - ``` - -> `build.sh`中会执行`git clone`获取第三方依赖库的代码,请提前确保git的网络设置正确可用。 - -以0.7.0-beta版本为例,x86_64架构Release版本编译完成之后,进入`mindspore/output`目录,执行如下解压缩命令,即可获取输出件`include`、`lib`、`benchmark`、`time_profiler`、`converter`和`third_party`。 - -```bash -tar -xvf mindspore-lite-0.7.0-converter-ubuntu.tar.gz -tar -xvf mindspore-lite-0.7.0-runtime-x86-cpu.tar.gz -``` - -## Windows环境部署 - -### 环境要求 - -- 编译环境仅支持32位或64位Windows系统 - -- 编译依赖(基本项) - - [CMake](https://cmake.org/download/) >= 3.14.1 - - [MinGW GCC](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z/download) >= 7.3.0 - - [Python](https://www.python.org/) >= 3.7.5 - - [Git](https://git-scm.com/downloads) >= 2.28.0 - -### 编译选项 - -MindSpore Lite的编译选项如下。 - -| 参数 | 参数说明 | 取值范围 | 是否必选 | -| -------- | ----- | ---- | ---- | -| lite | 设置该参数,则对Mindspore Lite工程进行编译,否则对Mindspore工程进行编译 | - | 是 | -| [n] | 设定编译时所用的线程数,否则默认设定为6线程 | - | 否 | - -### 输出件说明 - -编译完成后,进入源码的`mindspore/output/`目录,可查看编译后生成的文件,命名为`mindspore-lite-{version}-converter-win-{process_unit}.zip`。解压后,即可获得编译后的工具包,名称为`mindspore-lite-{version}`。 - -> version:输出件版本,与所编译的MindSpore版本一致。 -> process_unit:输出件应部署的处理器类型。 - -### 编译示例 - -首先,使用git工具从MindSpore代码仓下载源码。 - -```bash -git clone https://gitee.com/mindspore/mindspore.git -``` - -然后,使用cmd工具在源码根目录下,执行如下命令即可编译MindSpore Lite。 - -- 以默认线程数(6线程)编译Windows版本。 - ```bash - call build.bat lite - ``` -- 以指定线程数8编译Windows版本。 - ```bash - call build.bat lite 8 - ``` - -> `build.bat`中会执行`git clone`获取第三方依赖库的代码,请提前确保git的网络设置正确可用。 - -编译完成之后,进入`mindspore/output/`目录,解压后即可获取输出件`converter`。 -- Gitee