提交 8afbb380 编写于 作者: chrisxu2014's avatar chrisxu2014 提交者: GitHub

Merge branch 'gh-pages' into gh-pages

......@@ -207,6 +207,11 @@ trans_full_matrix_projection
Aggregate Layers
================
AggregateLevel
--------------
.. autoclass:: paddle.v2.layer.AggregateLevel
:noindex:
.. _api_v2.layer_pooling:
pooling
......@@ -248,6 +253,11 @@ block_expand
.. _api_v2.layer_expand:
ExpandLevel
-----------
.. autoclass:: paddle.v2.layer.ExpandLevel
:noindex:
expand
------
.. autoclass:: paddle.v2.layer.expand
......
A few months ago when we were trying to replace CMake with Bazel, @emailweixu suggested that we rewrite those handy Bazel functions using CMake. Now it seems that it's the right time to get this done, as we are facing problems from the porting of Majel and the development of new the parameter server using Go and C++.
Here are some initial thoughts. Your comments are welcome!
### Required CMake Function
I think we need only the following few CMake functions to make a project description mean and clean:
| C++ | CUDA C++ | Go |
|---|---|---|
| cc_library | nv_library | go_library |
| cc_binary | nv_binary | go_binary |
| cc_test | nv_test | go_test |
- The `_library` functions generate .a files from source code.
- The `_binary` functions generate executable binary files.
- The `_test` functions generate executable unit test files. They work like `_binary` but links `-lgtest` and `-lgtest_main`.
The difference between `nv_` functions and `cc_` functions is that the former use `nvcc` instead of the system-default C++ compiler.
Both `nv_` and `cc_` functions enables C++11 (-std=c++11).
Also,
- to describe external dependencies, we need `external_library`.
- to build shared libraries, we need `shared_library`.
### An Example Project
Suppose that we have aforementioned functions defined in our `/cmake` directory. The following example `CMakeLists.txt` describes a project including the following source files:
- tensor.h
- tensor.cc
- tensor_test.cc
- ops.h
- ops.cu
- ops_test.cu
- api.go
- api_test.go
Suppose that ops.cu depends on CUDNN.
```cmake
# cc_binary parses tensor.cc and figures out that target also depend
# on tensor.h.
cc_binary(tensor
SRCS
tensor.cc)
# The dependency to target tensor implies that if any of
# tensor{.h,.cc,_test.cc} is changed, tensor_test need to be re-built.
cc_test(tensor_test
SRCS
tensor_test.cc
DEPS
tensor)
# I don't have a clear idea what parameters external_library need to
# have. @gangliao as a CMake expert would have better ideas.
external_library(cudnn
....)
# Suppose that ops.cu depends on external target CUDNN. Also, ops.cu
# include global functions that take Tensor as their parameters, so
# ops depend on tensor. This implies that if any of tensor.{h.cc},
# ops.{h,cu} is changed, ops need to be re-built.
nv_library(ops
SRCS
ops.cu
DEPS
tensor
cudnn) # cudnn is defined later.
nv_test(ops_test
SRCS
ops_test.cu
DEPS
ops)
# Because api.go defines a GO wrapper to ops and tensor, it depends on
# both. This implies that if any of tensor.{h,cc}, ops.{h,cu}, or
# api.go is changed, api need to be re-built.
go_library(api
SRCS
api.go
DEPS
tensor # Because ops depend on tensor, this line is optional.
ops)
go_test(api_test
SRCS
api_test.go
DEPS
api)
# This builds libapi.so. shared_library might use CMake target
# api_shared so to distinguish it from above target api.
shared_library(api
DEPS
api)
```
### Implementation
As above example CMakeLists.txt executes, each function invocation adds "nodes" to a dependency graph. It also use this graph to generate CMake commands including `add_executable`, `add_dependencies`, `target_link_libraries`, and `add_test`.
# FileManager设计文档
## 目标
在本文档中,我们设计说明了名为FileManager系统,方便用户上传自己的训练数据以进行分布式训练
主要功能包括:
- 提供常用的命令行管理命令管理文件和目录
- 支持大文件的断点上传、下载
## 名词解释
- PFS:是`Paddlepaddle cloud File System`的缩写,是对用户文件存储空间的抽象,与之相对的是local filesystem。目前我们用CephFS来搭建。
- [CephFS](http://docs.ceph.com/docs/master/cephfs/):一个POSIX兼容的文件系统。
- Chunk:逻辑划上文件分块的单位。
## 模块
### 架构图
<image src=./src/filemanager.png width=900>
### PFSClient
- 功能: 详细设计[link](./pfs/pfsclient.md)
- 提供用户管理文件的命令
- 需要可以跨平台执行
- 双向验证
PFSClient需要和Ingress之间做双向验证<sup>[tls](#tls)</sup>,所以用户需要首先在`cloud.paddlepaddle.org`上注册一下,申请用户空间,并且把系统生成的CA(certificate authority)、Key、CRT(CA signed certificate)下载到本地,然后才能使用PFSClient。
### [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/)
- 功能:
提供七层协议的反向代理、基于粘性会话的负载均衡功能。
- 透传用户身份的办法
Ingress需要把PFSClient的身份信息传给PFSServer,配置的方法参考[link](http://www.integralist.co.uk/posts/clientcertauth.html#3)
### PFSServer
PFSServer提供RESTful API接口,接收处理PFSClient端的文件管理请求,并且把结果返回PFSClient端。
RESTful API
- /api/v1/files
- `GET /api/v1/files`: Get metadata of files or directories.
- `POST /api/v1/files`: Create files or directories.
- `PATCH /api/v1/files`: Update files or directories.
- `DELETE /api/v1/files`: Delete files or directories.
- /api/v1/file/chunks
- `GET /api/v1/storage/file/chunks`: Get chunks's metadata of a file.
- /api/v1/storage/files
- `GET /api/v1/storage/files`: Download files or directories.
- `POST /api/v1/storage/files`: Upload files or directories.
- /api/v1/storage/file/chunks
- `GET /api/v1/storage/file/chunks`: Download chunks's data.
- `POST /api/v1/storage/file/chunks`: Upload chunks's data.
## 文件传输优化
### 分块文件传输
用户文件可能是比较大的,上传到Cloud或者下载到本地的时间可能比较长,而且在传输的过程中也可能出现网络不稳定的情况。为了应对以上的问题,我们提出了Chunk的概念,一个Chunk由所在的文件偏移、数据、数据长度及校验值组成。文件的上传和下载都是通过对Chunk的操作来实现的。由于Chunk比较小(默认256K),完成一个传输动作完成的时间也比较短,不容易出错。PFSClient需要在传输完毕最后一个Chunk的时候检查destination文件的MD5值是否和source文件一致。
一个典型的Chunk如下所示:
```
type Chunk struct {
fileOffset int64
checksum uint32
len uint32
data []byte
}
```
### 生成sparse文件
当destination文件不存在或者大小和source文件不一致时,可以用[Fallocate](https://Go.org/pkg/syscall/#Fallocate)生成sparse文件,然后就可以并发写入多个Chunk。
### 覆盖不一致的部分
文件传输的的关键在于需要PFSClient端对比source和destination的文件Chunks的checksum是否保持一致,不一致的由PFSClient下载或者传输Chunk完成。这样已经传输成功的部分就不用重新传输了。
## 用户使用流程
参考[link](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md)
## 框架生成
用[swagger](https://github.com/swagger-api/swagger-codegen)生成PFSClient和PFSServer的框架部分,以便我们可以把更多的精力放到逻辑本身上。
## 参考文档
- <a name=tls></a>[TLS complete guide](https://github.com/k8sp/tls/blob/master/tls.md)
- [aws.s3](http://docs.aws.amazon.com/cli/latest/reference/s3/)
- [linux man document](https://linux.die.net/man/)
# PFSClient
## Description
The `pfs` command is a Command Line Interface to manage your files on PaddlePaddle Cloud
## Synopsis
```
paddle [options] pfs <subcommand> [parameters]
```
## Options
```
--profile (string)
Use a specific profile from your credential file.
--help (string)
Display more information about command
--version
Output version information and exit
--debug
Show detailed debugging log
--only-show-errors (boolean)
Only errors and warnings are displayed. All other output is suppressed.
```
## Path Arguments
When using a command, we need to specify path arguments. There are two path argument type: `localpath` and `pfspath`.
A `pfspath` begin with `/pfs`, eg: `/pfs/$DATACENTER/home/$USER/folder`.
[Here](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md#上传训练文件) is how to config datacenters.
## order of Path Arguments
Commonly, if there are two path arguments, the first is the source, and the second is the destination.
## Subcommonds
- rm - remove files or directories
```
Synopsis:
rm [-r] [-v] <PFSPath> ...
Options:
-r
Remove directories and their contents recursively
-v
Cause rm to be verbose, showing files after they are removed.
Examples:
paddle pfs rm /pfs/$DATACENTER/home/$USER/file
paddle pfs rm -r /pfs/$DATACENTER/home/$USER/folder
```
- mv - move (rename) files
```
Synopsis:
mv [-f | -n] [-v] <LocalPath> <PFSPath>
mv [-f | -n] [-v] <LocalPath> ... <PFSPath>
mv [-f | -n] [-v] <PFSPath> <LocalPath>
mv [-f | -n] [-v] <PFSPath> ... <LocalPath>
mv [-f | -n] [-v] <PFSPath> <PFSPath>
mv [-f | -n] [-v] <PFSPath> ... <PFSPath>
Options:
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause mv to be verbose, showing files after they are moved.
Examples:
paddle pfs mv ./text1.txt /pfs/$DATACENTER/home/$USER/text1.txt
```
- cp - copy files or directories
```
Synopsis:
cp [-r] [-f | -n] [-v] [--preserve--links] <LocalPath> <PFSPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <LocalPath> ... <PFSPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> <LocalPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> ... <LocalPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> <PFSPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> ... <PFSPath>
Options:
-r
Copy directories recursively
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause cp to be verbose, showing files after they are copied.
--preserve--links
Reserve links when copy links
Examples:
paddle pfs cp ./file /pfs/$DATACENTER/home/$USER/file
paddle pfs cp /pfs/$DATACENTER/home/$USER/file ./file
```
- ls- list files
```
Synopsis:
ls [-r] <PFSPath> ...
Options:
-R
List directory(ies) recursively
Examples:
paddle pfs ls /pfs/$DATACENTER/home/$USER/file
paddle pfs ls /pfs/$DATACENTER/home/$USER/folder
```
- mkdir - mkdir directory(ies)
Create intermediate directory(ies) as required.
```
Synopsis:
mkdir <PFSPath> ...
Examples:
paddle pfs mkdir /pfs/$DATACENTER/home/$USER/folder
```
......@@ -1793,6 +1793,30 @@ The simply usage is:</p>
</div>
<div class="section" id="aggregate-layers">
<h2>Aggregate Layers<a class="headerlink" href="#aggregate-layers" title="Permalink to this headline"></a></h2>
<div class="section" id="aggregatelevel">
<h3>AggregateLevel<a class="headerlink" href="#aggregatelevel" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">AggregateLevel</code></dt>
<dd><p>PaddlePaddle supports three sequence types:</p>
<ul class="simple">
<li><code class="code docutils literal"><span class="pre">SequenceType.NO_SEQUENCE</span></code> means the sample is not a sequence.</li>
<li><code class="code docutils literal"><span class="pre">SequenceType.SEQUENCE</span></code> means the sample is a sequence.</li>
<li><code class="code docutils literal"><span class="pre">SequenceType.SUB_SEQUENCE</span></code> means the sample is a nested sequence,
each timestep of which is also a sequence.</li>
</ul>
<p>Accordingly, AggregateLevel supports two modes:</p>
<ul class="simple">
<li><code class="code docutils literal"><span class="pre">AggregateLevel.EACH_TIMESTEP</span></code> means the aggregation acts on each
timestep of a sequence, both <code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code> and <code class="code docutils literal"><span class="pre">SEQUENCE</span></code> will
be aggregated to <code class="code docutils literal"><span class="pre">NO_SEQUENCE</span></code>.</li>
<li><code class="code docutils literal"><span class="pre">AggregateLevel.EACH_SEQUENCE</span></code> means the aggregation acts on each
sequence of a nested sequence, <code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code> will be aggregated to
<code class="code docutils literal"><span class="pre">SEQUENCE</span></code>.</li>
</ul>
</dd></dl>
</div>
<div class="section" id="api-v2-layer-pooling">
<span id="id1"></span><h3>pooling<a class="headerlink" href="#api-v2-layer-pooling" title="Permalink to this headline"></a></h3>
<dl class="class">
......@@ -2049,9 +2073,27 @@ convolution neural network, and before recurrent neural network.</p>
</table>
</dd></dl>
</div>
<div class="section" id="expandlevel">
<span id="api-v2-layer-expand"></span><h3>ExpandLevel<a class="headerlink" href="#expandlevel" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">ExpandLevel</code></dt>
<dd><p>Please refer to AggregateLevel first.</p>
<p>ExpandLevel supports two modes:</p>
<ul class="simple">
<li><code class="code docutils literal"><span class="pre">ExpandLevel.FROM_TIMESTEP</span></code> means the expandation acts on each
timestep of a sequence, <code class="code docutils literal"><span class="pre">NO_SEQUENCE</span></code> will be expanded to
<code class="code docutils literal"><span class="pre">SEQUENCE</span></code> or <code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code>.</li>
<li><code class="code docutils literal"><span class="pre">ExpandLevel.FROM_SEQUENCE</span></code> means the expandation acts on each
sequence of a nested sequence, <code class="code docutils literal"><span class="pre">SEQUENCE</span></code> will be expanded to
<code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code>.</li>
</ul>
</dd></dl>
</div>
<div class="section" id="expand">
<span id="api-v2-layer-expand"></span><h3>expand<a class="headerlink" href="#expand" title="Permalink to this headline"></a></h3>
<h3>expand<a class="headerlink" href="#expand" title="Permalink to this headline"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">expand</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span></dt>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Required CMake Function &mdash; PaddlePaddle documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="PaddlePaddle documentation" href="../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_en.html">GET STARTED</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_en.html">HOW TO</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_en.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about/index_en.html">ABOUT</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_en.html">GET STARTED</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/build_and_install/index_en.html">Install and Build</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/docker_install_en.html">PaddlePaddle in Docker Containers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/ubuntu_install_en.html">Debian Package installation guide</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/build_from_source_en.html">Installing from Sources</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_en.html">HOW TO</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cmd_parameter/index_en.html">Set Command-line Parameters</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/use_case_en.html">Use Case</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/arguments_en.html">Argument Outline</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/detail_introduction_en.html">Detail Description</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cluster/cluster_train_en.html">Run Distributed Training</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_en.html">Paddle On Kubernetes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_aws_en.html">Distributed PaddlePaddle Training on AWS with Kubernetes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/new_layer_en.html">Write New Layers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/contribute_to_paddle_en.html">Contribute Code</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/deep_model/rnn/index_en.html">RNN Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/optimization/gpu_profiling_en.html">Tune GPU Performance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_en.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/model_configs.html">Model Configuration</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/data.html">Data Reader Interface and DataSets</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/run_logic.html">Training and Inference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../about/index_en.html">ABOUT</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>Required CMake Function</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<p>A few months ago when we were trying to replace CMake with Bazel, &#64;emailweixu suggested that we rewrite those handy Bazel functions using CMake. Now it seems that it&#8217;s the right time to get this done, as we are facing problems from the porting of Majel and the development of new the parameter server using Go and C++.</p>
<p>Here are some initial thoughts. Your comments are welcome!</p>
<div class="section" id="required-cmake-function">
<span id="required-cmake-function"></span><h1>Required CMake Function<a class="headerlink" href="#required-cmake-function" title="Permalink to this headline"></a></h1>
<p>I think we need only the following few CMake functions to make a project description mean and clean:</p>
<p>| C++ | CUDA C++ | Go |
|&#8212;|&#8212;|&#8212;|
| cc_library | nv_library | go_library |
| cc_binary | nv_binary | go_binary |
| cc_test | nv_test | go_test |</p>
<ul class="simple">
<li>The <code class="docutils literal"><span class="pre">_library</span></code> functions generate .a files from source code.</li>
<li>The <code class="docutils literal"><span class="pre">_binary</span></code> functions generate executable binary files.</li>
<li>The <code class="docutils literal"><span class="pre">_test</span></code> functions generate executable unit test files. They work like <code class="docutils literal"><span class="pre">_binary</span></code> but links <code class="docutils literal"><span class="pre">-lgtest</span></code> and <code class="docutils literal"><span class="pre">-lgtest_main</span></code>.</li>
</ul>
<p>The difference between <code class="docutils literal"><span class="pre">nv_</span></code> functions and <code class="docutils literal"><span class="pre">cc_</span></code> functions is that the former use <code class="docutils literal"><span class="pre">nvcc</span></code> instead of the system-default C++ compiler.</p>
<p>Both <code class="docutils literal"><span class="pre">nv_</span></code> and <code class="docutils literal"><span class="pre">cc_</span></code> functions enables C++11 (-std=c++11).</p>
<p>Also,</p>
<ul class="simple">
<li>to describe external dependencies, we need <code class="docutils literal"><span class="pre">external_library</span></code>.</li>
<li>to build shared libraries, we need <code class="docutils literal"><span class="pre">shared_library</span></code>.</li>
</ul>
</div>
<div class="section" id="an-example-project">
<span id="an-example-project"></span><h1>An Example Project<a class="headerlink" href="#an-example-project" title="Permalink to this headline"></a></h1>
<p>Suppose that we have aforementioned functions defined in our <code class="docutils literal"><span class="pre">/cmake</span></code> directory. The following example <code class="docutils literal"><span class="pre">CMakeLists.txt</span></code> describes a project including the following source files:</p>
<ul class="simple">
<li>tensor.h</li>
<li>tensor.cc</li>
<li>tensor_test.cc</li>
<li>ops.h</li>
<li>ops.cu</li>
<li>ops_test.cu</li>
<li>api.go</li>
<li>api_test.go</li>
</ul>
<p>Suppose that ops.cu depends on CUDNN.</p>
<div class="highlight-cmake"><div class="highlight"><pre><span></span><span class="c"># cc_binary parses tensor.cc and figures out that target also depend</span>
<span class="c"># on tensor.h.</span>
<span class="nb">cc_binary</span><span class="p">(</span><span class="s">tensor</span>
<span class="s">SRCS</span>
<span class="s">tensor.cc</span><span class="p">)</span>
<span class="c"># The dependency to target tensor implies that if any of</span>
<span class="c"># tensor{.h,.cc,_test.cc} is changed, tensor_test need to be re-built.</span>
<span class="nb">cc_test</span><span class="p">(</span><span class="s">tensor_test</span>
<span class="s">SRCS</span>
<span class="s">tensor_test.cc</span>
<span class="s">DEPS</span>
<span class="s">tensor</span><span class="p">)</span>
<span class="c"># I don&#39;t have a clear idea what parameters external_library need to</span>
<span class="c"># have. @gangliao as a CMake expert would have better ideas.</span>
<span class="nb">external_library</span><span class="p">(</span><span class="s">cudnn</span>
<span class="s">....</span><span class="p">)</span>
<span class="c"># Suppose that ops.cu depends on external target CUDNN. Also, ops.cu</span>
<span class="c"># include global functions that take Tensor as their parameters, so</span>
<span class="c"># ops depend on tensor. This implies that if any of tensor.{h.cc},</span>
<span class="c"># ops.{h,cu} is changed, ops need to be re-built.</span>
<span class="nb">nv_library</span><span class="p">(</span><span class="s">ops</span>
<span class="s">SRCS</span>
<span class="s">ops.cu</span>
<span class="s">DEPS</span>
<span class="s">tensor</span>
<span class="s">cudnn</span><span class="p">)</span> <span class="c"># cudnn is defined later.</span>
<span class="nb">nv_test</span><span class="p">(</span><span class="s">ops_test</span>
<span class="s">SRCS</span>
<span class="s">ops_test.cu</span>
<span class="s">DEPS</span>
<span class="s">ops</span><span class="p">)</span>
<span class="c"># Because api.go defines a GO wrapper to ops and tensor, it depends on</span>
<span class="c"># both. This implies that if any of tensor.{h,cc}, ops.{h,cu}, or</span>
<span class="c"># api.go is changed, api need to be re-built.</span>
<span class="nb">go_library</span><span class="p">(</span><span class="s">api</span>
<span class="s">SRCS</span>
<span class="s">api.go</span>
<span class="s">DEPS</span>
<span class="s">tensor</span> <span class="c"># Because ops depend on tensor, this line is optional.</span>
<span class="s">ops</span><span class="p">)</span>
<span class="nb">go_test</span><span class="p">(</span><span class="s">api_test</span>
<span class="s">SRCS</span>
<span class="s">api_test.go</span>
<span class="s">DEPS</span>
<span class="s">api</span><span class="p">)</span>
<span class="c"># This builds libapi.so. shared_library might use CMake target</span>
<span class="c"># api_shared so to distinguish it from above target api.</span>
<span class="nb">shared_library</span><span class="p">(</span><span class="s">api</span>
<span class="s">DEPS</span>
<span class="s">api</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="implementation">
<span id="implementation"></span><h1>Implementation<a class="headerlink" href="#implementation" title="Permalink to this headline"></a></h1>
<p>As above example CMakeLists.txt executes, each function invocation adds &#8220;nodes&#8221; to a dependency graph. It also use this graph to generate CMake commands including <code class="docutils literal"><span class="pre">add_executable</span></code>, <code class="docutils literal"><span class="pre">add_dependencies</span></code>, <code class="docutils literal"><span class="pre">target_link_libraries</span></code>, and <code class="docutils literal"><span class="pre">add_test</span></code>.</p>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -197,7 +197,7 @@
<span id="id4"></span><h2>训练数据存储<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<p>我们选择<a class="reference external" href="http://docs.ceph.com/docs/master/cephfs/">CephFS</a>作为存储系统。</p>
<ul class="simple">
<li>无论是从<a class="reference external" href="design/file_manager/README.md">PFSClient</a>的角度,还是从<a class="reference external" href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">Pod</a>中运行任务的角度,统一用<code class="docutils literal"><span class="pre">/pfs/$DATACENTER/home/$USER</span></code>来访问用户自己的数据。</li>
<li>无论是从<a class="reference internal" href="../file_manager/README.html"><span class="doc">PFSClient</span></a>的角度,还是从<a class="reference external" href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">Pod</a>中运行任务的角度,统一用<code class="docutils literal"><span class="pre">/pfs/$DATACENTER/home/$USER</span></code>来访问用户自己的数据。</li>
<li><code class="docutils literal"><span class="pre">/pfs/$DATACENTER/common</span></code>下存放公共数据集合<ul>
<li>做只读挂载</li>
</ul>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FileManager设计文档 &mdash; PaddlePaddle documentation</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../genindex.html"/>
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="PaddlePaddle documentation" href="../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_en.html">GET STARTED</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_en.html">HOW TO</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_en.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about/index_en.html">ABOUT</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_en.html">GET STARTED</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/build_and_install/index_en.html">Install and Build</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/docker_install_en.html">PaddlePaddle in Docker Containers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/ubuntu_install_en.html">Debian Package installation guide</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/build_from_source_en.html">Installing from Sources</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_en.html">HOW TO</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cmd_parameter/index_en.html">Set Command-line Parameters</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/use_case_en.html">Use Case</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/arguments_en.html">Argument Outline</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/detail_introduction_en.html">Detail Description</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cluster/cluster_train_en.html">Run Distributed Training</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_en.html">Paddle On Kubernetes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_aws_en.html">Distributed PaddlePaddle Training on AWS with Kubernetes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/new_layer_en.html">Write New Layers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/contribute_to_paddle_en.html">Contribute Code</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/deep_model/rnn/index_en.html">RNN Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/optimization/gpu_profiling_en.html">Tune GPU Performance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_en.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/model_configs.html">Model Configuration</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/data.html">Data Reader Interface and DataSets</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/run_logic.html">Training and Inference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../about/index_en.html">ABOUT</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>FileManager设计文档</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="filemanager">
<span id="filemanager"></span><h1>FileManager设计文档<a class="headerlink" href="#filemanager" title="Permalink to this headline"></a></h1>
<div class="section" id="">
<span id="id1"></span><h2>目标<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<p>在本文档中,我们设计说明了名为FileManager系统,方便用户上传自己的训练数据以进行分布式训练</p>
<p>主要功能包括:</p>
<ul class="simple">
<li>提供常用的命令行管理命令管理文件和目录</li>
<li>支持大文件的断点上传、下载</li>
</ul>
</div>
<div class="section" id="">
<span id="id2"></span><h2>名词解释<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>PFS:是<code class="docutils literal"><span class="pre">Paddlepaddle</span> <span class="pre">cloud</span> <span class="pre">File</span> <span class="pre">System</span></code>的缩写,是对用户文件存储空间的抽象,与之相对的是local filesystem。目前我们用CephFS来搭建。</li>
<li><a class="reference external" href="http://docs.ceph.com/docs/master/cephfs/">CephFS</a>:一个POSIX兼容的文件系统。</li>
<li>Chunk:逻辑划上文件分块的单位。</li>
</ul>
</div>
<div class="section" id="">
<span id="id3"></span><h2>模块<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<div class="section" id="">
<span id="id4"></span><h3>架构图<a class="headerlink" href="#" title="Permalink to this headline"></a></h3>
<p><image src=./src/filemanager.png width=900></p>
</div>
<div class="section" id="pfsclient">
<span id="pfsclient"></span><h3>PFSClient<a class="headerlink" href="#pfsclient" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>功能: 详细设计<a class="reference internal" href="pfs/pfsclient.html"><span class="doc">link</span></a><ul>
<li>提供用户管理文件的命令</li>
<li>需要可以跨平台执行</li>
</ul>
</li>
<li>双向验证PFSClient需要和Ingress之间做双向验证<sup><a class="reference external" href="#tls">tls</a></sup>,所以用户需要首先在<code class="docutils literal"><span class="pre">cloud.paddlepaddle.org</span></code>上注册一下,申请用户空间,并且把系统生成的CA(certificate authority)、Key、CRT(CA signed certificate)下载到本地,然后才能使用PFSClient。</li>
</ul>
</div>
<div class="section" id="ingress">
<span id="ingress"></span><h3><a class="reference external" href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress</a><a class="headerlink" href="#ingress" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>功能:提供七层协议的反向代理、基于粘性会话的负载均衡功能。</li>
<li>透传用户身份的办法Ingress需要把PFSClient的身份信息传给PFSServer,配置的方法参考<a class="reference external" href="http://www.integralist.co.uk/posts/clientcertauth.html#3">link</a></li>
</ul>
</div>
<div class="section" id="pfsserver">
<span id="pfsserver"></span><h3>PFSServer<a class="headerlink" href="#pfsserver" title="Permalink to this headline"></a></h3>
<p>PFSServer提供RESTful API接口,接收处理PFSClient端的文件管理请求,并且把结果返回PFSClient端。</p>
<p>RESTful API</p>
<ul class="simple">
<li>/api/v1/files<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/files</span></code>: Get metadata of files or directories.</li>
<li><code class="docutils literal"><span class="pre">POST</span> <span class="pre">/api/v1/files</span></code>: Create files or directories.</li>
<li><code class="docutils literal"><span class="pre">PATCH</span> <span class="pre">/api/v1/files</span></code>: Update files or directories.</li>
<li><code class="docutils literal"><span class="pre">DELETE</span> <span class="pre">/api/v1/files</span></code>: Delete files or directories.</li>
</ul>
</li>
<li>/api/v1/file/chunks<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/storage/file/chunks</span></code>: Get chunks&#8217;s metadata of a file.</li>
</ul>
</li>
<li>/api/v1/storage/files<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/storage/files</span></code>: Download files or directories.</li>
<li><code class="docutils literal"><span class="pre">POST</span> <span class="pre">/api/v1/storage/files</span></code>: Upload files or directories.</li>
</ul>
</li>
<li>/api/v1/storage/file/chunks<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/storage/file/chunks</span></code>: Download chunks&#8217;s data.</li>
<li><code class="docutils literal"><span class="pre">POST</span> <span class="pre">/api/v1/storage/file/chunks</span></code>: Upload chunks&#8217;s data.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="">
<span id="id5"></span><h2>文件传输优化<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<div class="section" id="">
<span id="id6"></span><h3>分块文件传输<a class="headerlink" href="#" title="Permalink to this headline"></a></h3>
<p>用户文件可能是比较大的,上传到Cloud或者下载到本地的时间可能比较长,而且在传输的过程中也可能出现网络不稳定的情况。为了应对以上的问题,我们提出了Chunk的概念,一个Chunk由所在的文件偏移、数据、数据长度及校验值组成。文件的上传和下载都是通过对Chunk的操作来实现的。由于Chunk比较小(默认256K),完成一个传输动作完成的时间也比较短,不容易出错。PFSClient需要在传输完毕最后一个Chunk的时候检查destination文件的MD5值是否和source文件一致。</p>
<p>一个典型的Chunk如下所示:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">type</span> <span class="n">Chunk</span> <span class="n">struct</span> <span class="p">{</span>
<span class="n">fileOffset</span> <span class="n">int64</span>
<span class="n">checksum</span> <span class="n">uint32</span>
<span class="nb">len</span> <span class="n">uint32</span>
<span class="n">data</span> <span class="p">[]</span><span class="n">byte</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="sparse">
<span id="sparse"></span><h3>生成sparse文件<a class="headerlink" href="#sparse" title="Permalink to this headline"></a></h3>
<p>当destination文件不存在或者大小和source文件不一致时,可以用<a class="reference external" href="https://Go.org/pkg/syscall/#Fallocate">Fallocate</a>生成sparse文件,然后就可以并发写入多个Chunk。</p>
</div>
<div class="section" id="">
<span id="id7"></span><h3>覆盖不一致的部分<a class="headerlink" href="#" title="Permalink to this headline"></a></h3>
<p>文件传输的的关键在于需要PFSClient端对比source和destination的文件Chunks的checksum是否保持一致,不一致的由PFSClient下载或者传输Chunk完成。这样已经传输成功的部分就不用重新传输了。</p>
</div>
</div>
<div class="section" id="">
<span id="id8"></span><h2>用户使用流程<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<p>参考<a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md">link</a></p>
</div>
<div class="section" id="">
<span id="id9"></span><h2>框架生成<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://github.com/swagger-api/swagger-codegen">swagger</a>生成PFSClient和PFSServer的框架部分,以便我们可以把更多的精力放到逻辑本身上。</p>
</div>
<div class="section" id="">
<span id="id10"></span><h2>参考文档<a class="headerlink" href="#" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a name=tls></a><a class="reference external" href="https://github.com/k8sp/tls/blob/master/tls.md">TLS complete guide</a></li>
<li><a class="reference external" href="http://docs.aws.amazon.com/cli/latest/reference/s3/">aws.s3</a></li>
<li><a class="reference external" href="https://linux.die.net/man/">linux man document</a></li>
</ul>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PFSClient &mdash; PaddlePaddle documentation</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="../../../genindex.html"/>
<link rel="search" title="Search" href="../../../search.html"/>
<link rel="top" title="PaddlePaddle documentation" href="../../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../getstarted/index_en.html">GET STARTED</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../howto/index_en.html">HOW TO</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index_en.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../about/index_en.html">ABOUT</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../getstarted/index_en.html">GET STARTED</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../getstarted/build_and_install/index_en.html">Install and Build</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../getstarted/build_and_install/docker_install_en.html">PaddlePaddle in Docker Containers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../getstarted/build_and_install/ubuntu_install_en.html">Debian Package installation guide</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../getstarted/build_and_install/build_from_source_en.html">Installing from Sources</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../howto/index_en.html">HOW TO</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/cmd_parameter/index_en.html">Set Command-line Parameters</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/usage/cmd_parameter/use_case_en.html">Use Case</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/usage/cmd_parameter/arguments_en.html">Argument Outline</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/usage/cmd_parameter/detail_introduction_en.html">Detail Description</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/cluster/cluster_train_en.html">Run Distributed Training</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/k8s/k8s_en.html">Paddle On Kubernetes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/k8s/k8s_aws_en.html">Distributed PaddlePaddle Training on AWS with Kubernetes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/dev/new_layer_en.html">Write New Layers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/dev/contribute_to_paddle_en.html">Contribute Code</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/deep_model/rnn/index_en.html">RNN Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/optimization/gpu_profiling_en.html">Tune GPU Performance</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index_en.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../api/v2/model_configs.html">Model Configuration</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../api/v2/data.html">Data Reader Interface and DataSets</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api/v2/run_logic.html">Training and Inference</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../about/index_en.html">ABOUT</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>PFSClient</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="pfsclient">
<span id="pfsclient"></span><h1>PFSClient<a class="headerlink" href="#pfsclient" title="Permalink to this headline"></a></h1>
<div class="section" id="description">
<span id="description"></span><h2>Description<a class="headerlink" href="#description" title="Permalink to this headline"></a></h2>
<p>The <code class="docutils literal"><span class="pre">pfs</span></code> command is a Command Line Interface to manage your files on PaddlePaddle Cloud</p>
</div>
<div class="section" id="synopsis">
<span id="synopsis"></span><h2>Synopsis<a class="headerlink" href="#synopsis" title="Permalink to this headline"></a></h2>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">paddle</span> <span class="p">[</span><span class="n">options</span><span class="p">]</span> <span class="n">pfs</span> <span class="o">&lt;</span><span class="n">subcommand</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">parameters</span><span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="options">
<span id="options"></span><h2>Options<a class="headerlink" href="#options" title="Permalink to this headline"></a></h2>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">--</span><span class="n">profile</span> <span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="n">Use</span> <span class="n">a</span> <span class="n">specific</span> <span class="n">profile</span> <span class="kn">from</span> <span class="nn">your</span> <span class="n">credential</span> <span class="n">file</span><span class="o">.</span>
<span class="o">--</span><span class="n">help</span> <span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="n">Display</span> <span class="n">more</span> <span class="n">information</span> <span class="n">about</span> <span class="n">command</span>
<span class="o">--</span><span class="n">version</span>
<span class="n">Output</span> <span class="n">version</span> <span class="n">information</span> <span class="ow">and</span> <span class="n">exit</span>
<span class="o">--</span><span class="n">debug</span>
<span class="n">Show</span> <span class="n">detailed</span> <span class="n">debugging</span> <span class="n">log</span>
<span class="o">--</span><span class="n">only</span><span class="o">-</span><span class="n">show</span><span class="o">-</span><span class="n">errors</span> <span class="p">(</span><span class="n">boolean</span><span class="p">)</span>
<span class="n">Only</span> <span class="n">errors</span> <span class="ow">and</span> <span class="n">warnings</span> <span class="n">are</span> <span class="n">displayed</span><span class="o">.</span> <span class="n">All</span> <span class="n">other</span> <span class="n">output</span> <span class="ow">is</span> <span class="n">suppressed</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="path-arguments">
<span id="path-arguments"></span><h2>Path Arguments<a class="headerlink" href="#path-arguments" title="Permalink to this headline"></a></h2>
<p>When using a command, we need to specify path arguments. There are two path argument type: <code class="docutils literal"><span class="pre">localpath</span></code> and <code class="docutils literal"><span class="pre">pfspath</span></code>.</p>
<p>A <code class="docutils literal"><span class="pre">pfspath</span></code> begin with <code class="docutils literal"><span class="pre">/pfs</span></code>, eg: <code class="docutils literal"><span class="pre">/pfs/$DATACENTER/home/$USER/folder</span></code>.</p>
<p><a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md#上传训练文件">Here</a> is how to config datacenters.</p>
</div>
<div class="section" id="order-of-path-arguments">
<span id="order-of-path-arguments"></span><h2>order of Path Arguments<a class="headerlink" href="#order-of-path-arguments" title="Permalink to this headline"></a></h2>
<p>Commonly, if there are two path arguments, the first is the source, and the second is the destination.</p>
</div>
<div class="section" id="subcommonds">
<span id="subcommonds"></span><h2>Subcommonds<a class="headerlink" href="#subcommonds" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>rm - remove files or directories</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
rm [-r] [-v] &lt;PFSPath&gt; ...
Options:
-r
Remove directories and their contents recursively
-v
Cause rm to be verbose, showing files after they are removed.
Examples:
paddle pfs rm /pfs/$DATACENTER/home/$USER/file
paddle pfs rm -r /pfs/$DATACENTER/home/$USER/folder
</pre></div>
</div>
<ul class="simple">
<li>mv - move (rename) files</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
mv [-f | -n] [-v] &lt;LocalPath&gt; &lt;PFSPath&gt;
mv [-f | -n] [-v] &lt;LocalPath&gt; ... &lt;PFSPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; &lt;LocalPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; ... &lt;LocalPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; &lt;PFSPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; ... &lt;PFSPath&gt;
Options:
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause mv to be verbose, showing files after they are moved.
Examples:
paddle pfs mv ./text1.txt /pfs/$DATACENTER/home/$USER/text1.txt
</pre></div>
</div>
<ul class="simple">
<li>cp - copy files or directories</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;LocalPath&gt; &lt;PFSPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;LocalPath&gt; ... &lt;PFSPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; &lt;LocalPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; ... &lt;LocalPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; &lt;PFSPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; ... &lt;PFSPath&gt;
Options:
-r
Copy directories recursively
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause cp to be verbose, showing files after they are copied.
--preserve--links
Reserve links when copy links
Examples:
paddle pfs cp ./file /pfs/$DATACENTER/home/$USER/file
paddle pfs cp /pfs/$DATACENTER/home/$USER/file ./file
</pre></div>
</div>
<ul class="simple">
<li>ls- list files</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
ls [-r] &lt;PFSPath&gt; ...
Options:
-R
List directory(ies) recursively
Examples:
paddle pfs ls /pfs/$DATACENTER/home/$USER/file
paddle pfs ls /pfs/$DATACENTER/home/$USER/folder
</pre></div>
</div>
<ul class="simple">
<li>mkdir - mkdir directory(ies)
Create intermediate directory(ies) as required.</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
mkdir &lt;PFSPath&gt; ...
Examples:
paddle pfs mkdir /pfs/$DATACENTER/home/$USER/folder
</pre></div>
</div>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -207,6 +207,11 @@ trans_full_matrix_projection
Aggregate Layers
================
AggregateLevel
--------------
.. autoclass:: paddle.v2.layer.AggregateLevel
:noindex:
.. _api_v2.layer_pooling:
pooling
......@@ -248,6 +253,11 @@ block_expand
.. _api_v2.layer_expand:
ExpandLevel
-----------
.. autoclass:: paddle.v2.layer.ExpandLevel
:noindex:
expand
------
.. autoclass:: paddle.v2.layer.expand
......
A few months ago when we were trying to replace CMake with Bazel, @emailweixu suggested that we rewrite those handy Bazel functions using CMake. Now it seems that it's the right time to get this done, as we are facing problems from the porting of Majel and the development of new the parameter server using Go and C++.
Here are some initial thoughts. Your comments are welcome!
### Required CMake Function
I think we need only the following few CMake functions to make a project description mean and clean:
| C++ | CUDA C++ | Go |
|---|---|---|
| cc_library | nv_library | go_library |
| cc_binary | nv_binary | go_binary |
| cc_test | nv_test | go_test |
- The `_library` functions generate .a files from source code.
- The `_binary` functions generate executable binary files.
- The `_test` functions generate executable unit test files. They work like `_binary` but links `-lgtest` and `-lgtest_main`.
The difference between `nv_` functions and `cc_` functions is that the former use `nvcc` instead of the system-default C++ compiler.
Both `nv_` and `cc_` functions enables C++11 (-std=c++11).
Also,
- to describe external dependencies, we need `external_library`.
- to build shared libraries, we need `shared_library`.
### An Example Project
Suppose that we have aforementioned functions defined in our `/cmake` directory. The following example `CMakeLists.txt` describes a project including the following source files:
- tensor.h
- tensor.cc
- tensor_test.cc
- ops.h
- ops.cu
- ops_test.cu
- api.go
- api_test.go
Suppose that ops.cu depends on CUDNN.
```cmake
# cc_binary parses tensor.cc and figures out that target also depend
# on tensor.h.
cc_binary(tensor
SRCS
tensor.cc)
# The dependency to target tensor implies that if any of
# tensor{.h,.cc,_test.cc} is changed, tensor_test need to be re-built.
cc_test(tensor_test
SRCS
tensor_test.cc
DEPS
tensor)
# I don't have a clear idea what parameters external_library need to
# have. @gangliao as a CMake expert would have better ideas.
external_library(cudnn
....)
# Suppose that ops.cu depends on external target CUDNN. Also, ops.cu
# include global functions that take Tensor as their parameters, so
# ops depend on tensor. This implies that if any of tensor.{h.cc},
# ops.{h,cu} is changed, ops need to be re-built.
nv_library(ops
SRCS
ops.cu
DEPS
tensor
cudnn) # cudnn is defined later.
nv_test(ops_test
SRCS
ops_test.cu
DEPS
ops)
# Because api.go defines a GO wrapper to ops and tensor, it depends on
# both. This implies that if any of tensor.{h,cc}, ops.{h,cu}, or
# api.go is changed, api need to be re-built.
go_library(api
SRCS
api.go
DEPS
tensor # Because ops depend on tensor, this line is optional.
ops)
go_test(api_test
SRCS
api_test.go
DEPS
api)
# This builds libapi.so. shared_library might use CMake target
# api_shared so to distinguish it from above target api.
shared_library(api
DEPS
api)
```
### Implementation
As above example CMakeLists.txt executes, each function invocation adds "nodes" to a dependency graph. It also use this graph to generate CMake commands including `add_executable`, `add_dependencies`, `target_link_libraries`, and `add_test`.
# FileManager设计文档
## 目标
在本文档中,我们设计说明了名为FileManager系统,方便用户上传自己的训练数据以进行分布式训练
主要功能包括:
- 提供常用的命令行管理命令管理文件和目录
- 支持大文件的断点上传、下载
## 名词解释
- PFS:是`Paddlepaddle cloud File System`的缩写,是对用户文件存储空间的抽象,与之相对的是local filesystem。目前我们用CephFS来搭建。
- [CephFS](http://docs.ceph.com/docs/master/cephfs/):一个POSIX兼容的文件系统。
- Chunk:逻辑划上文件分块的单位。
## 模块
### 架构图
<image src=./src/filemanager.png width=900>
### PFSClient
- 功能: 详细设计[link](./pfs/pfsclient.md)
- 提供用户管理文件的命令
- 需要可以跨平台执行
- 双向验证
PFSClient需要和Ingress之间做双向验证<sup>[tls](#tls)</sup>,所以用户需要首先在`cloud.paddlepaddle.org`上注册一下,申请用户空间,并且把系统生成的CA(certificate authority)、Key、CRT(CA signed certificate)下载到本地,然后才能使用PFSClient。
### [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/)
- 功能:
提供七层协议的反向代理、基于粘性会话的负载均衡功能。
- 透传用户身份的办法
Ingress需要把PFSClient的身份信息传给PFSServer,配置的方法参考[link](http://www.integralist.co.uk/posts/clientcertauth.html#3)
### PFSServer
PFSServer提供RESTful API接口,接收处理PFSClient端的文件管理请求,并且把结果返回PFSClient端。
RESTful API
- /api/v1/files
- `GET /api/v1/files`: Get metadata of files or directories.
- `POST /api/v1/files`: Create files or directories.
- `PATCH /api/v1/files`: Update files or directories.
- `DELETE /api/v1/files`: Delete files or directories.
- /api/v1/file/chunks
- `GET /api/v1/storage/file/chunks`: Get chunks's metadata of a file.
- /api/v1/storage/files
- `GET /api/v1/storage/files`: Download files or directories.
- `POST /api/v1/storage/files`: Upload files or directories.
- /api/v1/storage/file/chunks
- `GET /api/v1/storage/file/chunks`: Download chunks's data.
- `POST /api/v1/storage/file/chunks`: Upload chunks's data.
## 文件传输优化
### 分块文件传输
用户文件可能是比较大的,上传到Cloud或者下载到本地的时间可能比较长,而且在传输的过程中也可能出现网络不稳定的情况。为了应对以上的问题,我们提出了Chunk的概念,一个Chunk由所在的文件偏移、数据、数据长度及校验值组成。文件的上传和下载都是通过对Chunk的操作来实现的。由于Chunk比较小(默认256K),完成一个传输动作完成的时间也比较短,不容易出错。PFSClient需要在传输完毕最后一个Chunk的时候检查destination文件的MD5值是否和source文件一致。
一个典型的Chunk如下所示:
```
type Chunk struct {
fileOffset int64
checksum uint32
len uint32
data []byte
}
```
### 生成sparse文件
当destination文件不存在或者大小和source文件不一致时,可以用[Fallocate](https://Go.org/pkg/syscall/#Fallocate)生成sparse文件,然后就可以并发写入多个Chunk。
### 覆盖不一致的部分
文件传输的的关键在于需要PFSClient端对比source和destination的文件Chunks的checksum是否保持一致,不一致的由PFSClient下载或者传输Chunk完成。这样已经传输成功的部分就不用重新传输了。
## 用户使用流程
参考[link](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md)
## 框架生成
用[swagger](https://github.com/swagger-api/swagger-codegen)生成PFSClient和PFSServer的框架部分,以便我们可以把更多的精力放到逻辑本身上。
## 参考文档
- <a name=tls></a>[TLS complete guide](https://github.com/k8sp/tls/blob/master/tls.md)
- [aws.s3](http://docs.aws.amazon.com/cli/latest/reference/s3/)
- [linux man document](https://linux.die.net/man/)
# PFSClient
## Description
The `pfs` command is a Command Line Interface to manage your files on PaddlePaddle Cloud
## Synopsis
```
paddle [options] pfs <subcommand> [parameters]
```
## Options
```
--profile (string)
Use a specific profile from your credential file.
--help (string)
Display more information about command
--version
Output version information and exit
--debug
Show detailed debugging log
--only-show-errors (boolean)
Only errors and warnings are displayed. All other output is suppressed.
```
## Path Arguments
When using a command, we need to specify path arguments. There are two path argument type: `localpath` and `pfspath`.
A `pfspath` begin with `/pfs`, eg: `/pfs/$DATACENTER/home/$USER/folder`.
[Here](https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md#上传训练文件) is how to config datacenters.
## order of Path Arguments
Commonly, if there are two path arguments, the first is the source, and the second is the destination.
## Subcommonds
- rm - remove files or directories
```
Synopsis:
rm [-r] [-v] <PFSPath> ...
Options:
-r
Remove directories and their contents recursively
-v
Cause rm to be verbose, showing files after they are removed.
Examples:
paddle pfs rm /pfs/$DATACENTER/home/$USER/file
paddle pfs rm -r /pfs/$DATACENTER/home/$USER/folder
```
- mv - move (rename) files
```
Synopsis:
mv [-f | -n] [-v] <LocalPath> <PFSPath>
mv [-f | -n] [-v] <LocalPath> ... <PFSPath>
mv [-f | -n] [-v] <PFSPath> <LocalPath>
mv [-f | -n] [-v] <PFSPath> ... <LocalPath>
mv [-f | -n] [-v] <PFSPath> <PFSPath>
mv [-f | -n] [-v] <PFSPath> ... <PFSPath>
Options:
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause mv to be verbose, showing files after they are moved.
Examples:
paddle pfs mv ./text1.txt /pfs/$DATACENTER/home/$USER/text1.txt
```
- cp - copy files or directories
```
Synopsis:
cp [-r] [-f | -n] [-v] [--preserve--links] <LocalPath> <PFSPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <LocalPath> ... <PFSPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> <LocalPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> ... <LocalPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> <PFSPath>
cp [-r] [-f | -n] [-v] [--preserve--links] <PFSPath> ... <PFSPath>
Options:
-r
Copy directories recursively
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause cp to be verbose, showing files after they are copied.
--preserve--links
Reserve links when copy links
Examples:
paddle pfs cp ./file /pfs/$DATACENTER/home/$USER/file
paddle pfs cp /pfs/$DATACENTER/home/$USER/file ./file
```
- ls- list files
```
Synopsis:
ls [-r] <PFSPath> ...
Options:
-R
List directory(ies) recursively
Examples:
paddle pfs ls /pfs/$DATACENTER/home/$USER/file
paddle pfs ls /pfs/$DATACENTER/home/$USER/folder
```
- mkdir - mkdir directory(ies)
Create intermediate directory(ies) as required.
```
Synopsis:
mkdir <PFSPath> ...
Examples:
paddle pfs mkdir /pfs/$DATACENTER/home/$USER/folder
```
# 构建Android平台上的PaddlePaddle库
用户可通过交叉编译的方式,在用户熟悉的开发平台(Linux,Mac OS X和Windows)上编译Android平台上适用的PaddlePaddle库。
本文档将以Linux x86-64平台为例,介绍交叉编译Android平台上适用的PaddlePaddle库的方法和步骤。
## 准备交叉编译环境
从源码交叉编译PaddlePaddle,用户需要提前准备好交叉编译环境。Android平台上使用的C/C++交叉编译工具链为[Android NDK](https://developer.android.com/ndk/downloads/index.html?hl=zh-cn),用户可自行前往下载预编译好的版本,也可通过以下命令获取:
```bash
wget -q https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
unzip -q android-ndk-r14b-linux-x86_64.zip
```
Android NDK中包含了所有Android API级别、所有架构(arm/arm64/x86/mips)需要用到的编译工具和系统库。用户可根据自己的编译目标架构、所需支持的最低Android API级别,构建[独立工具链](https://developer.android.google.cn/ndk/guides/standalone_toolchain.html?hl=zh-cn)。
比如:
```bash
your/path/to/android-ndk-r14b-linux-x86_64/build/tools/make-standalone-toolchain.sh \
--arch=arm --platform=android-21 --install-dir=your/path/to/my_standalone_toolchain
```
此命令将在your/path/to/my_standalone_toolchain目录生成一套编译工具链,面向架构为32位ARM架构,支持的最小的Android API级别为21,使用的编译器为arm-linux-androideabi-gcc (GCC) 4.9。
注意:**PaddlePaddle要求使用的编译工具链所支持的Andoid API级别不小于21**。
## 配置交叉编译参数
CMake系统对交叉编译提供了支持[cmake-toolchains](https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html#cross-compiling)。为了简化cmake配置,PaddlePaddle为交叉编译提供了工具链配置文档[cmake/cross_compiling/android.cmake](https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/cross_compiling/android.cmake),以提供一些默认的编译器和编译参数相关配置。注意,从CMake 3.7版本开始,CMake官方对Android平台的交叉编译提供了通用的支持。PaddlePaddle若检测到用户使用的CMake版本不低于3.7时,将会将用户传进来的配置参数传递CMake系统,交由CMake系统本身来处理。有关参数配置的详细说明见[cmake-toolchains](https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling)。
交叉编译Android版本的PaddlePaddle库时,有一些必须配置的参数:
- `CMAKE_SYSTEM_NAME`,CMake编译的目标平台,必须设置为`Android`。在设置`CMAKE_SYSTEM_NAME=Android`后,PaddlePaddle的CMake系统才认为是在交叉编译Android系统的版本,并自动编译宿主机版protoc可执行文件、目标机版protobuf库、以及Android所需`arm_soft_fp_abi`分支的目标机版OpenBLAS库。此外,还会强制设置一些PaddlePaddle参数的值(`WITH_GPU=OFF`、`WITH_AVX=OFF`、`WITH_PYTHON=OFF`、`WITH_RDMA=OFF`)。
- `WITH_C_API`,必须设置为`ON`。在Android平台上只支持使用C-API来预测。
- `WITH_SWIG_PY`,必须设置为`OFF`。在Android平台上不支持通过swig调用来训练或者预测。
Android平台可选配置参数:
- `ANDROID_STANDALONE_TOOLCHAIN`,独立工具链所在的绝对路径,或者相对于构建目录的相对路径。PaddlePaddle的CMake系统将根据该值自动推导和设置需要使用的交叉编译器、sysroot、以及Android API级别;否则,用户需要在cmake时手动设置这些值。无默认值。
- `ANDROID_ABI`,目标架构ABI。目前只支持`armeabi-v7a`,默认值为`armeabi-v7a`。
- `ANDROID_NATIVE_API_LEVEL`,工具链的Android API级别。若没有显式设置,PaddlePaddle将根据`ANDROID_STANDALONE_TOOLCHAIN`的值自动推导得到。
- `ANROID_ARM_MODE`,是否使用ARM模式。可设置`ON/OFF`,默认值为`ON`。
- `ANDROID_ARM_NEON`,是否使用NEON指令。目前必须设置成`ON`,默认值为`ON`。
其他配置参数:
- `HOST_C/CXX_COMPILER`,宿主机的C/C++编译器。在编译宿主机版protoc可执行文件和目标机版OpenBLAS库时需要用到。默认设置成环境变量`CC`的值;若环境变量`CC`没有设置,则设置成`cc`编译器。
一种常用的cmake配置如下:
```bash
cmake -DCMAKE_SYSTEM_NAME=Android \
-DANDROID_STANDALONE_TOOLCHAIN=your/path/to/my_standalone_toolchain \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_ARM_NEON=ON \
-DANDROID_ARM_MODE=ON \
-DCMAKE_INSTALL_PREFIX=your/path/to/install \
-DWITH_C_API=ON \
-DWITH_SWIG_PY=OFF \
..
```
用户还可根据自己的需求设置其他编译参数。比如希望最小化生成的库的大小,可以设置`CMAKE_BUILD_TYPE`为`MinSizeRel`;若希望最快的执行速度,则可设置`CMAKE_BUILD_TYPE`为`Release`。亦可以通过手动设置`CMAKE_C/CXX_FLAGS_MINSIZEREL/RELEASE`来影响PaddlePaddle的编译过程。
## 编译和安装
CMake配置完成后,执行以下命令,PaddlePaddle将自动下载和编译所有第三方依赖库、编译和安装PaddlePaddle预测库。
```bash
make
make install
```
注意:如果你曾经在源码目录下编译过其他平台的PaddlePaddle库,请先使用`rm -rf`命令删除`third_party`目录和`build`目录,以确保所有的第三方依赖库和PaddlePaddle代码都是针对新的CMake配置重新编译的。
执行完安装命令后,`your/path/to/install`目录中会包含`include`和`lib`目录,其中`include`中包含C-API的头文件,`lib`中包含一个Android版本的库。自此,PaddlePaddle的已经安装完成,用户可将`your/path/to/install`目录下的生成文件用于深度学习相关Android App中,调用方法见C-API文档。
# 构建Raspberry Pi平台上的PaddlePaddle库
对于Rasspberry Pi系统,用户可通过ssh等方式登录到Raspberry Pi系统上,按照[源码编译PaddlePaddle](http://www.paddlepaddle.org/doc_cn/getstarted/build_and_install/cmake/build_from_source_cn.html)相关文档所述,直接编译Raspberry Pi平台上适用的PaddlePaddle库。
用户也可以在自己熟悉的开发平台上,通过交叉编译的方式来编译。这篇文档将以Linux x86-64平台为例,介绍交叉编译Raspberry Pi平台上适用的PaddlePaddle的方法和步骤。
## 准备交叉编译环境
从源码交叉编译PaddlePaddle,用户需要提前准备好交叉编译环境。用户可自行前往[github](https://github.com/raspberrypi/tools)下载Raspberry Pi平台使用的C/C++交叉编译工具链,也可通过以下命令获取:
```bash
git clone https://github.com/raspberrypi/tools.git
```
该github仓库中包含若干个预编译好的、针对不同平台的编译工具。宿主机是Linux x86-64环境,则需选用`arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64`下的作为编译工具,所使用的编译器为arm-linux-gnueabihf-gcc 4.8.3。
注意,该编译工具链需要系统glibc支持2.14以上。
## 配置交叉编译参数
CMake系统对交叉编译提供了支持[cmake-toolchains](https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html#cross-compiling)。为了简化cmake配置,PaddlePaddle为交叉编译提供了工具链配置文档[cmake/cross_compiling/raspberry_pi.cmake](https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/cross_compiling/raspberry_pi.cmake),以提供一些默认的编译器和编译参数相关配置。
交叉编译Raspberry Pi版本PaddlePaddle库时,有一些必须配置的参数:
- `CMAKE_SYSTEM_NAME`,CMake编译的目标平台,必须配置为`RPi`。在设置`CMAKE_SYSTEM_NAME=RPi`后,PaddlePaddle的CMake系统才认为在是在交叉编译Raspberry Pi系统的版本,并自动编译宿主机版protoc可执行文件、目标机版protobuf库、以及目标机版OpenBLAS库。
Raspberry Pi平台可选配置参数:
- `RPI_TOOLCHAIN`,编译工具链所在的绝对路径,或者相对于构建目录的相对路径。PaddlePaddle的CMake系统将根据该值自动设置需要使用的交叉编译器;否则,用户需要在cmake时手动设置这些值。无默认值。
- `RPI_ARM_NEON`,是否使用NEON指令。目前必须设置成`ON`,默认值为`ON`。
其他配置参数:
- `HOST_C/CXX_COMPILER`,宿主机的C/C++编译器。在编译宿主机版protoc可执行文件和目标机版OpenBLAS库时需要用到。默认设置成环境变量`CC`的值;若环境变量`CC`没有设置,则设置成`cc`编译器。
cmake参数如下;
```
cmake -DCMAKE_SYSTEM_NAME=RPi \
-DRPI_TOOLCHAIN=your/path/to/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64 \
-DRPI_ARM_NEON=ON \
-DCMAKE_INSTALL_PREFIX=your/path/to/install \
-DWITH_GPU=OFF \
-DWITH_C_API=ON \
-DWITH_PYTHON=OFF \
-DWITH_SWIG_PY=OFF \
..
```
用户还可根据自己的需求设置其他编译参数。比如希望最小化生成的库的大小,可以设置`CMAKE_BUILD_TYPE`为`MinSizeRel`;若希望最快的执行速度,则可设置`CMAKE_BUILD_TYPE`为`Release`。亦可以通过手动设置`CMAKE_C/CXX_FLAGS_MINSIZEREL/RELEASE`来影响PaddlePaddle的编译过程。
## 编译和安装
CMake配置完成后,执行以下命令,PaddlePaddle将自动下载和编译所有第三方依赖库、编译和安装PaddlePaddle。
```bash
make
make install
```
注意:如果你曾经在源码目录下编译过其他平台的PaddlePaddle库,请先使用`rm -rf`命令删除`third_party`目录和`build`目录,以确保所有的第三方依赖库和PaddlePaddle代码都是针对新的CMake配置重新编译的。
执行完安装命令后,由于上一步cmake配置中`WITH_C_API`设置为`ON`,`your/path/to/install`目录中会包含`include`和`lib`目录,其中`include`中包含C-API的头文件,`lib`中包含一个Raspberry Pi版本的库。
更多的编译配置见[源码编译PaddlePaddle](http://www.paddlepaddle.org/doc_cn/getstarted/build_and_install/cmake/build_from_source_cn.html)相关文档。
......@@ -1800,6 +1800,30 @@ The simply usage is:</p>
</div>
<div class="section" id="aggregate-layers">
<h2>Aggregate Layers<a class="headerlink" href="#aggregate-layers" title="永久链接至标题"></a></h2>
<div class="section" id="aggregatelevel">
<h3>AggregateLevel<a class="headerlink" href="#aggregatelevel" title="永久链接至标题"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">AggregateLevel</code></dt>
<dd><p>PaddlePaddle supports three sequence types:</p>
<ul class="simple">
<li><code class="code docutils literal"><span class="pre">SequenceType.NO_SEQUENCE</span></code> means the sample is not a sequence.</li>
<li><code class="code docutils literal"><span class="pre">SequenceType.SEQUENCE</span></code> means the sample is a sequence.</li>
<li><code class="code docutils literal"><span class="pre">SequenceType.SUB_SEQUENCE</span></code> means the sample is a nested sequence,
each timestep of which is also a sequence.</li>
</ul>
<p>Accordingly, AggregateLevel supports two modes:</p>
<ul class="simple">
<li><code class="code docutils literal"><span class="pre">AggregateLevel.EACH_TIMESTEP</span></code> means the aggregation acts on each
timestep of a sequence, both <code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code> and <code class="code docutils literal"><span class="pre">SEQUENCE</span></code> will
be aggregated to <code class="code docutils literal"><span class="pre">NO_SEQUENCE</span></code>.</li>
<li><code class="code docutils literal"><span class="pre">AggregateLevel.EACH_SEQUENCE</span></code> means the aggregation acts on each
sequence of a nested sequence, <code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code> will be aggregated to
<code class="code docutils literal"><span class="pre">SEQUENCE</span></code>.</li>
</ul>
</dd></dl>
</div>
<div class="section" id="api-v2-layer-pooling">
<span id="id1"></span><h3>pooling<a class="headerlink" href="#api-v2-layer-pooling" title="永久链接至标题"></a></h3>
<dl class="class">
......@@ -2056,9 +2080,27 @@ convolution neural network, and before recurrent neural network.</p>
</table>
</dd></dl>
</div>
<div class="section" id="expandlevel">
<span id="api-v2-layer-expand"></span><h3>ExpandLevel<a class="headerlink" href="#expandlevel" title="永久链接至标题"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">ExpandLevel</code></dt>
<dd><p>Please refer to AggregateLevel first.</p>
<p>ExpandLevel supports two modes:</p>
<ul class="simple">
<li><code class="code docutils literal"><span class="pre">ExpandLevel.FROM_TIMESTEP</span></code> means the expandation acts on each
timestep of a sequence, <code class="code docutils literal"><span class="pre">NO_SEQUENCE</span></code> will be expanded to
<code class="code docutils literal"><span class="pre">SEQUENCE</span></code> or <code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code>.</li>
<li><code class="code docutils literal"><span class="pre">ExpandLevel.FROM_SEQUENCE</span></code> means the expandation acts on each
sequence of a nested sequence, <code class="code docutils literal"><span class="pre">SEQUENCE</span></code> will be expanded to
<code class="code docutils literal"><span class="pre">SUB_SEQUENCE</span></code>.</li>
</ul>
</dd></dl>
</div>
<div class="section" id="expand">
<span id="api-v2-layer-expand"></span><h3>expand<a class="headerlink" href="#expand" title="永久链接至标题"></a></h3>
<h3>expand<a class="headerlink" href="#expand" title="永久链接至标题"></a></h3>
<dl class="class">
<dt>
<em class="property">class </em><code class="descclassname">paddle.v2.layer.</code><code class="descname">expand</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span></dt>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Required CMake Function &mdash; PaddlePaddle 文档</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../../genindex.html"/>
<link rel="search" title="搜索" href="../../search.html"/>
<link rel="top" title="PaddlePaddle 文档" href="../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_cn.html">进阶指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/build_and_install/index_cn.html">安装与编译</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/docker_install_cn.html">PaddlePaddle的Docker容器使用方式</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/ubuntu_install_cn.html">Ubuntu部署PaddlePaddle</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/cmake/build_from_source_cn.html">PaddlePaddle的编译选项</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/concepts/use_concepts_cn.html">基本使用概念</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_cn.html">进阶指南</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cmd_parameter/index_cn.html">设置命令行参数</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/use_case_cn.html">使用案例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/arguments_cn.html">参数概述</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/detail_introduction_cn.html">细节描述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cluster/cluster_train_cn.html">运行分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_basis_cn.html">Kubernetes 简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_cn.html">Kubernetes单机训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_distributed_cn.html">Kubernetes分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/write_docs_cn.html">如何贡献/修改文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/contribute_to_paddle_cn.html">如何贡献代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/deep_model/rnn/index_cn.html">RNN相关模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../howto/deep_model/rnn/recurrent_group_cn.html">Recurrent Group教程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/deep_model/rnn/hierarchical_layer_cn.html">支持双层序列作为输入的Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/deep_model/rnn/hrnn_rnn_api_compare_cn.html">单双层RNN API对比介绍</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/optimization/gpu_profiling_cn.html">GPU性能分析与调优</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/model_configs.html">模型配置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/data.html">数据访问</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/run_logic.html">训练与应用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>Required CMake Function</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<p>A few months ago when we were trying to replace CMake with Bazel, &#64;emailweixu suggested that we rewrite those handy Bazel functions using CMake. Now it seems that it&#8217;s the right time to get this done, as we are facing problems from the porting of Majel and the development of new the parameter server using Go and C++.</p>
<p>Here are some initial thoughts. Your comments are welcome!</p>
<div class="section" id="required-cmake-function">
<span id="required-cmake-function"></span><h1>Required CMake Function<a class="headerlink" href="#required-cmake-function" title="永久链接至标题"></a></h1>
<p>I think we need only the following few CMake functions to make a project description mean and clean:</p>
<p>| C++ | CUDA C++ | Go |
|&#8212;|&#8212;|&#8212;|
| cc_library | nv_library | go_library |
| cc_binary | nv_binary | go_binary |
| cc_test | nv_test | go_test |</p>
<ul class="simple">
<li>The <code class="docutils literal"><span class="pre">_library</span></code> functions generate .a files from source code.</li>
<li>The <code class="docutils literal"><span class="pre">_binary</span></code> functions generate executable binary files.</li>
<li>The <code class="docutils literal"><span class="pre">_test</span></code> functions generate executable unit test files. They work like <code class="docutils literal"><span class="pre">_binary</span></code> but links <code class="docutils literal"><span class="pre">-lgtest</span></code> and <code class="docutils literal"><span class="pre">-lgtest_main</span></code>.</li>
</ul>
<p>The difference between <code class="docutils literal"><span class="pre">nv_</span></code> functions and <code class="docutils literal"><span class="pre">cc_</span></code> functions is that the former use <code class="docutils literal"><span class="pre">nvcc</span></code> instead of the system-default C++ compiler.</p>
<p>Both <code class="docutils literal"><span class="pre">nv_</span></code> and <code class="docutils literal"><span class="pre">cc_</span></code> functions enables C++11 (-std=c++11).</p>
<p>Also,</p>
<ul class="simple">
<li>to describe external dependencies, we need <code class="docutils literal"><span class="pre">external_library</span></code>.</li>
<li>to build shared libraries, we need <code class="docutils literal"><span class="pre">shared_library</span></code>.</li>
</ul>
</div>
<div class="section" id="an-example-project">
<span id="an-example-project"></span><h1>An Example Project<a class="headerlink" href="#an-example-project" title="永久链接至标题"></a></h1>
<p>Suppose that we have aforementioned functions defined in our <code class="docutils literal"><span class="pre">/cmake</span></code> directory. The following example <code class="docutils literal"><span class="pre">CMakeLists.txt</span></code> describes a project including the following source files:</p>
<ul class="simple">
<li>tensor.h</li>
<li>tensor.cc</li>
<li>tensor_test.cc</li>
<li>ops.h</li>
<li>ops.cu</li>
<li>ops_test.cu</li>
<li>api.go</li>
<li>api_test.go</li>
</ul>
<p>Suppose that ops.cu depends on CUDNN.</p>
<div class="highlight-cmake"><div class="highlight"><pre><span></span><span class="c"># cc_binary parses tensor.cc and figures out that target also depend</span>
<span class="c"># on tensor.h.</span>
<span class="nb">cc_binary</span><span class="p">(</span><span class="s">tensor</span>
<span class="s">SRCS</span>
<span class="s">tensor.cc</span><span class="p">)</span>
<span class="c"># The dependency to target tensor implies that if any of</span>
<span class="c"># tensor{.h,.cc,_test.cc} is changed, tensor_test need to be re-built.</span>
<span class="nb">cc_test</span><span class="p">(</span><span class="s">tensor_test</span>
<span class="s">SRCS</span>
<span class="s">tensor_test.cc</span>
<span class="s">DEPS</span>
<span class="s">tensor</span><span class="p">)</span>
<span class="c"># I don&#39;t have a clear idea what parameters external_library need to</span>
<span class="c"># have. @gangliao as a CMake expert would have better ideas.</span>
<span class="nb">external_library</span><span class="p">(</span><span class="s">cudnn</span>
<span class="s">....</span><span class="p">)</span>
<span class="c"># Suppose that ops.cu depends on external target CUDNN. Also, ops.cu</span>
<span class="c"># include global functions that take Tensor as their parameters, so</span>
<span class="c"># ops depend on tensor. This implies that if any of tensor.{h.cc},</span>
<span class="c"># ops.{h,cu} is changed, ops need to be re-built.</span>
<span class="nb">nv_library</span><span class="p">(</span><span class="s">ops</span>
<span class="s">SRCS</span>
<span class="s">ops.cu</span>
<span class="s">DEPS</span>
<span class="s">tensor</span>
<span class="s">cudnn</span><span class="p">)</span> <span class="c"># cudnn is defined later.</span>
<span class="nb">nv_test</span><span class="p">(</span><span class="s">ops_test</span>
<span class="s">SRCS</span>
<span class="s">ops_test.cu</span>
<span class="s">DEPS</span>
<span class="s">ops</span><span class="p">)</span>
<span class="c"># Because api.go defines a GO wrapper to ops and tensor, it depends on</span>
<span class="c"># both. This implies that if any of tensor.{h,cc}, ops.{h,cu}, or</span>
<span class="c"># api.go is changed, api need to be re-built.</span>
<span class="nb">go_library</span><span class="p">(</span><span class="s">api</span>
<span class="s">SRCS</span>
<span class="s">api.go</span>
<span class="s">DEPS</span>
<span class="s">tensor</span> <span class="c"># Because ops depend on tensor, this line is optional.</span>
<span class="s">ops</span><span class="p">)</span>
<span class="nb">go_test</span><span class="p">(</span><span class="s">api_test</span>
<span class="s">SRCS</span>
<span class="s">api_test.go</span>
<span class="s">DEPS</span>
<span class="s">api</span><span class="p">)</span>
<span class="c"># This builds libapi.so. shared_library might use CMake target</span>
<span class="c"># api_shared so to distinguish it from above target api.</span>
<span class="nb">shared_library</span><span class="p">(</span><span class="s">api</span>
<span class="s">DEPS</span>
<span class="s">api</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="implementation">
<span id="implementation"></span><h1>Implementation<a class="headerlink" href="#implementation" title="永久链接至标题"></a></h1>
<p>As above example CMakeLists.txt executes, each function invocation adds &#8220;nodes&#8221; to a dependency graph. It also use this graph to generate CMake commands including <code class="docutils literal"><span class="pre">add_executable</span></code>, <code class="docutils literal"><span class="pre">add_dependencies</span></code>, <code class="docutils literal"><span class="pre">target_link_libraries</span></code>, and <code class="docutils literal"><span class="pre">add_test</span></code>.</p>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/translations.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -204,7 +204,7 @@
<span id="id4"></span><h2>训练数据存储<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>我们选择<a class="reference external" href="http://docs.ceph.com/docs/master/cephfs/">CephFS</a>作为存储系统。</p>
<ul class="simple">
<li>无论是从<a class="reference external" href="design/file_manager/README.md">PFSClient</a>的角度,还是从<a class="reference external" href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">Pod</a>中运行任务的角度,统一用<code class="docutils literal"><span class="pre">/pfs/$DATACENTER/home/$USER</span></code>来访问用户自己的数据。</li>
<li>无论是从<a class="reference internal" href="../file_manager/README.html"><span class="doc">PFSClient</span></a>的角度,还是从<a class="reference external" href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">Pod</a>中运行任务的角度,统一用<code class="docutils literal"><span class="pre">/pfs/$DATACENTER/home/$USER</span></code>来访问用户自己的数据。</li>
<li><code class="docutils literal"><span class="pre">/pfs/$DATACENTER/common</span></code>下存放公共数据集合<ul>
<li>做只读挂载</li>
</ul>
......
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FileManager设计文档 &mdash; PaddlePaddle 文档</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../../genindex.html"/>
<link rel="search" title="搜索" href="../../search.html"/>
<link rel="top" title="PaddlePaddle 文档" href="../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_cn.html">进阶指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/build_and_install/index_cn.html">安装与编译</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/docker_install_cn.html">PaddlePaddle的Docker容器使用方式</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/ubuntu_install_cn.html">Ubuntu部署PaddlePaddle</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/cmake/build_from_source_cn.html">PaddlePaddle的编译选项</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/concepts/use_concepts_cn.html">基本使用概念</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../howto/index_cn.html">进阶指南</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cmd_parameter/index_cn.html">设置命令行参数</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/use_case_cn.html">使用案例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/arguments_cn.html">参数概述</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/usage/cmd_parameter/detail_introduction_cn.html">细节描述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/cluster/cluster_train_cn.html">运行分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_basis_cn.html">Kubernetes 简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_cn.html">Kubernetes单机训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/usage/k8s/k8s_distributed_cn.html">Kubernetes分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/write_docs_cn.html">如何贡献/修改文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/dev/contribute_to_paddle_cn.html">如何贡献代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/deep_model/rnn/index_cn.html">RNN相关模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../howto/deep_model/rnn/recurrent_group_cn.html">Recurrent Group教程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/deep_model/rnn/hierarchical_layer_cn.html">支持双层序列作为输入的Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../howto/deep_model/rnn/hrnn_rnn_api_compare_cn.html">单双层RNN API对比介绍</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../howto/optimization/gpu_profiling_cn.html">GPU性能分析与调优</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/model_configs.html">模型配置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/data.html">数据访问</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/run_logic.html">训练与应用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>FileManager设计文档</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="filemanager">
<span id="filemanager"></span><h1>FileManager设计文档<a class="headerlink" href="#filemanager" title="永久链接至标题"></a></h1>
<div class="section" id="">
<span id="id1"></span><h2>目标<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>在本文档中,我们设计说明了名为FileManager系统,方便用户上传自己的训练数据以进行分布式训练</p>
<p>主要功能包括:</p>
<ul class="simple">
<li>提供常用的命令行管理命令管理文件和目录</li>
<li>支持大文件的断点上传、下载</li>
</ul>
</div>
<div class="section" id="">
<span id="id2"></span><h2>名词解释<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<ul class="simple">
<li>PFS:是<code class="docutils literal"><span class="pre">Paddlepaddle</span> <span class="pre">cloud</span> <span class="pre">File</span> <span class="pre">System</span></code>的缩写,是对用户文件存储空间的抽象,与之相对的是local filesystem。目前我们用CephFS来搭建。</li>
<li><a class="reference external" href="http://docs.ceph.com/docs/master/cephfs/">CephFS</a>:一个POSIX兼容的文件系统。</li>
<li>Chunk:逻辑划上文件分块的单位。</li>
</ul>
</div>
<div class="section" id="">
<span id="id3"></span><h2>模块<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<div class="section" id="">
<span id="id4"></span><h3>架构图<a class="headerlink" href="#" title="永久链接至标题"></a></h3>
<p><image src=./src/filemanager.png width=900></p>
</div>
<div class="section" id="pfsclient">
<span id="pfsclient"></span><h3>PFSClient<a class="headerlink" href="#pfsclient" title="永久链接至标题"></a></h3>
<ul class="simple">
<li>功能: 详细设计<a class="reference internal" href="pfs/pfsclient.html"><span class="doc">link</span></a><ul>
<li>提供用户管理文件的命令</li>
<li>需要可以跨平台执行</li>
</ul>
</li>
<li>双向验证PFSClient需要和Ingress之间做双向验证<sup><a class="reference external" href="#tls">tls</a></sup>,所以用户需要首先在<code class="docutils literal"><span class="pre">cloud.paddlepaddle.org</span></code>上注册一下,申请用户空间,并且把系统生成的CA(certificate authority)、Key、CRT(CA signed certificate)下载到本地,然后才能使用PFSClient。</li>
</ul>
</div>
<div class="section" id="ingress">
<span id="ingress"></span><h3><a class="reference external" href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress</a><a class="headerlink" href="#ingress" title="永久链接至标题"></a></h3>
<ul class="simple">
<li>功能:提供七层协议的反向代理、基于粘性会话的负载均衡功能。</li>
<li>透传用户身份的办法Ingress需要把PFSClient的身份信息传给PFSServer,配置的方法参考<a class="reference external" href="http://www.integralist.co.uk/posts/clientcertauth.html#3">link</a></li>
</ul>
</div>
<div class="section" id="pfsserver">
<span id="pfsserver"></span><h3>PFSServer<a class="headerlink" href="#pfsserver" title="永久链接至标题"></a></h3>
<p>PFSServer提供RESTful API接口,接收处理PFSClient端的文件管理请求,并且把结果返回PFSClient端。</p>
<p>RESTful API</p>
<ul class="simple">
<li>/api/v1/files<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/files</span></code>: Get metadata of files or directories.</li>
<li><code class="docutils literal"><span class="pre">POST</span> <span class="pre">/api/v1/files</span></code>: Create files or directories.</li>
<li><code class="docutils literal"><span class="pre">PATCH</span> <span class="pre">/api/v1/files</span></code>: Update files or directories.</li>
<li><code class="docutils literal"><span class="pre">DELETE</span> <span class="pre">/api/v1/files</span></code>: Delete files or directories.</li>
</ul>
</li>
<li>/api/v1/file/chunks<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/storage/file/chunks</span></code>: Get chunks&#8217;s metadata of a file.</li>
</ul>
</li>
<li>/api/v1/storage/files<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/storage/files</span></code>: Download files or directories.</li>
<li><code class="docutils literal"><span class="pre">POST</span> <span class="pre">/api/v1/storage/files</span></code>: Upload files or directories.</li>
</ul>
</li>
<li>/api/v1/storage/file/chunks<ul>
<li><code class="docutils literal"><span class="pre">GET</span> <span class="pre">/api/v1/storage/file/chunks</span></code>: Download chunks&#8217;s data.</li>
<li><code class="docutils literal"><span class="pre">POST</span> <span class="pre">/api/v1/storage/file/chunks</span></code>: Upload chunks&#8217;s data.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="">
<span id="id5"></span><h2>文件传输优化<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<div class="section" id="">
<span id="id6"></span><h3>分块文件传输<a class="headerlink" href="#" title="永久链接至标题"></a></h3>
<p>用户文件可能是比较大的,上传到Cloud或者下载到本地的时间可能比较长,而且在传输的过程中也可能出现网络不稳定的情况。为了应对以上的问题,我们提出了Chunk的概念,一个Chunk由所在的文件偏移、数据、数据长度及校验值组成。文件的上传和下载都是通过对Chunk的操作来实现的。由于Chunk比较小(默认256K),完成一个传输动作完成的时间也比较短,不容易出错。PFSClient需要在传输完毕最后一个Chunk的时候检查destination文件的MD5值是否和source文件一致。</p>
<p>一个典型的Chunk如下所示:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">type</span> <span class="n">Chunk</span> <span class="n">struct</span> <span class="p">{</span>
<span class="n">fileOffset</span> <span class="n">int64</span>
<span class="n">checksum</span> <span class="n">uint32</span>
<span class="nb">len</span> <span class="n">uint32</span>
<span class="n">data</span> <span class="p">[]</span><span class="n">byte</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="sparse">
<span id="sparse"></span><h3>生成sparse文件<a class="headerlink" href="#sparse" title="永久链接至标题"></a></h3>
<p>当destination文件不存在或者大小和source文件不一致时,可以用<a class="reference external" href="https://Go.org/pkg/syscall/#Fallocate">Fallocate</a>生成sparse文件,然后就可以并发写入多个Chunk。</p>
</div>
<div class="section" id="">
<span id="id7"></span><h3>覆盖不一致的部分<a class="headerlink" href="#" title="永久链接至标题"></a></h3>
<p>文件传输的的关键在于需要PFSClient端对比source和destination的文件Chunks的checksum是否保持一致,不一致的由PFSClient下载或者传输Chunk完成。这样已经传输成功的部分就不用重新传输了。</p>
</div>
</div>
<div class="section" id="">
<span id="id8"></span><h2>用户使用流程<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>参考<a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md">link</a></p>
</div>
<div class="section" id="">
<span id="id9"></span><h2>框架生成<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p><a class="reference external" href="https://github.com/swagger-api/swagger-codegen">swagger</a>生成PFSClient和PFSServer的框架部分,以便我们可以把更多的精力放到逻辑本身上。</p>
</div>
<div class="section" id="">
<span id="id10"></span><h2>参考文档<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<ul class="simple">
<li><a name=tls></a><a class="reference external" href="https://github.com/k8sp/tls/blob/master/tls.md">TLS complete guide</a></li>
<li><a class="reference external" href="http://docs.aws.amazon.com/cli/latest/reference/s3/">aws.s3</a></li>
<li><a class="reference external" href="https://linux.die.net/man/">linux man document</a></li>
</ul>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/translations.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PFSClient &mdash; PaddlePaddle 文档</title>
<link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../../../genindex.html"/>
<link rel="search" title="搜索" href="../../../search.html"/>
<link rel="top" title="PaddlePaddle 文档" href="../../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../getstarted/index_cn.html">新手入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../howto/index_cn.html">进阶指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index_cn.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../faq/index_cn.html">FAQ</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../getstarted/index_cn.html">新手入门</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../getstarted/build_and_install/index_cn.html">安装与编译</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../getstarted/build_and_install/docker_install_cn.html">PaddlePaddle的Docker容器使用方式</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../getstarted/build_and_install/ubuntu_install_cn.html">Ubuntu部署PaddlePaddle</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../getstarted/build_and_install/cmake/build_from_source_cn.html">PaddlePaddle的编译选项</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../getstarted/concepts/use_concepts_cn.html">基本使用概念</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../howto/index_cn.html">进阶指南</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/cmd_parameter/index_cn.html">设置命令行参数</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/usage/cmd_parameter/use_case_cn.html">使用案例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/usage/cmd_parameter/arguments_cn.html">参数概述</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/usage/cmd_parameter/detail_introduction_cn.html">细节描述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/cluster/cluster_train_cn.html">运行分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/k8s/k8s_basis_cn.html">Kubernetes 简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/k8s/k8s_cn.html">Kubernetes单机训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/usage/k8s/k8s_distributed_cn.html">Kubernetes分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/dev/write_docs_cn.html">如何贡献/修改文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/dev/contribute_to_paddle_cn.html">如何贡献代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/deep_model/rnn/index_cn.html">RNN相关模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/deep_model/rnn/recurrent_group_cn.html">Recurrent Group教程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/deep_model/rnn/hierarchical_layer_cn.html">支持双层序列作为输入的Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../howto/deep_model/rnn/hrnn_rnn_api_compare_cn.html">单双层RNN API对比介绍</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../howto/optimization/gpu_profiling_cn.html">GPU性能分析与调优</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/index_cn.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../../api/v2/model_configs.html">模型配置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../api/v2/data.html">数据访问</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../api/v2/run_logic.html">训练与应用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../faq/index_cn.html">FAQ</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>PFSClient</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="pfsclient">
<span id="pfsclient"></span><h1>PFSClient<a class="headerlink" href="#pfsclient" title="永久链接至标题"></a></h1>
<div class="section" id="description">
<span id="description"></span><h2>Description<a class="headerlink" href="#description" title="永久链接至标题"></a></h2>
<p>The <code class="docutils literal"><span class="pre">pfs</span></code> command is a Command Line Interface to manage your files on PaddlePaddle Cloud</p>
</div>
<div class="section" id="synopsis">
<span id="synopsis"></span><h2>Synopsis<a class="headerlink" href="#synopsis" title="永久链接至标题"></a></h2>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">paddle</span> <span class="p">[</span><span class="n">options</span><span class="p">]</span> <span class="n">pfs</span> <span class="o">&lt;</span><span class="n">subcommand</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">parameters</span><span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="options">
<span id="options"></span><h2>Options<a class="headerlink" href="#options" title="永久链接至标题"></a></h2>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">--</span><span class="n">profile</span> <span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="n">Use</span> <span class="n">a</span> <span class="n">specific</span> <span class="n">profile</span> <span class="kn">from</span> <span class="nn">your</span> <span class="n">credential</span> <span class="n">file</span><span class="o">.</span>
<span class="o">--</span><span class="n">help</span> <span class="p">(</span><span class="n">string</span><span class="p">)</span>
<span class="n">Display</span> <span class="n">more</span> <span class="n">information</span> <span class="n">about</span> <span class="n">command</span>
<span class="o">--</span><span class="n">version</span>
<span class="n">Output</span> <span class="n">version</span> <span class="n">information</span> <span class="ow">and</span> <span class="n">exit</span>
<span class="o">--</span><span class="n">debug</span>
<span class="n">Show</span> <span class="n">detailed</span> <span class="n">debugging</span> <span class="n">log</span>
<span class="o">--</span><span class="n">only</span><span class="o">-</span><span class="n">show</span><span class="o">-</span><span class="n">errors</span> <span class="p">(</span><span class="n">boolean</span><span class="p">)</span>
<span class="n">Only</span> <span class="n">errors</span> <span class="ow">and</span> <span class="n">warnings</span> <span class="n">are</span> <span class="n">displayed</span><span class="o">.</span> <span class="n">All</span> <span class="n">other</span> <span class="n">output</span> <span class="ow">is</span> <span class="n">suppressed</span><span class="o">.</span>
</pre></div>
</div>
</div>
<div class="section" id="path-arguments">
<span id="path-arguments"></span><h2>Path Arguments<a class="headerlink" href="#path-arguments" title="永久链接至标题"></a></h2>
<p>When using a command, we need to specify path arguments. There are two path argument type: <code class="docutils literal"><span class="pre">localpath</span></code> and <code class="docutils literal"><span class="pre">pfspath</span></code>.</p>
<p>A <code class="docutils literal"><span class="pre">pfspath</span></code> begin with <code class="docutils literal"><span class="pre">/pfs</span></code>, eg: <code class="docutils literal"><span class="pre">/pfs/$DATACENTER/home/$USER/folder</span></code>.</p>
<p><a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/cluster_train/data_dispatch.md#上传训练文件">Here</a> is how to config datacenters.</p>
</div>
<div class="section" id="order-of-path-arguments">
<span id="order-of-path-arguments"></span><h2>order of Path Arguments<a class="headerlink" href="#order-of-path-arguments" title="永久链接至标题"></a></h2>
<p>Commonly, if there are two path arguments, the first is the source, and the second is the destination.</p>
</div>
<div class="section" id="subcommonds">
<span id="subcommonds"></span><h2>Subcommonds<a class="headerlink" href="#subcommonds" title="永久链接至标题"></a></h2>
<ul class="simple">
<li>rm - remove files or directories</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
rm [-r] [-v] &lt;PFSPath&gt; ...
Options:
-r
Remove directories and their contents recursively
-v
Cause rm to be verbose, showing files after they are removed.
Examples:
paddle pfs rm /pfs/$DATACENTER/home/$USER/file
paddle pfs rm -r /pfs/$DATACENTER/home/$USER/folder
</pre></div>
</div>
<ul class="simple">
<li>mv - move (rename) files</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
mv [-f | -n] [-v] &lt;LocalPath&gt; &lt;PFSPath&gt;
mv [-f | -n] [-v] &lt;LocalPath&gt; ... &lt;PFSPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; &lt;LocalPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; ... &lt;LocalPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; &lt;PFSPath&gt;
mv [-f | -n] [-v] &lt;PFSPath&gt; ... &lt;PFSPath&gt;
Options:
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause mv to be verbose, showing files after they are moved.
Examples:
paddle pfs mv ./text1.txt /pfs/$DATACENTER/home/$USER/text1.txt
</pre></div>
</div>
<ul class="simple">
<li>cp - copy files or directories</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;LocalPath&gt; &lt;PFSPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;LocalPath&gt; ... &lt;PFSPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; &lt;LocalPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; ... &lt;LocalPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; &lt;PFSPath&gt;
cp [-r] [-f | -n] [-v] [--preserve--links] &lt;PFSPath&gt; ... &lt;PFSPath&gt;
Options:
-r
Copy directories recursively
-f
Do not prompt for confirmation before overwriting the destination path. (The -f option overrides previous -n options.)
-n
Do not overwrite an existing file. (The -n option overrides previous -f options.)
-v
Cause cp to be verbose, showing files after they are copied.
--preserve--links
Reserve links when copy links
Examples:
paddle pfs cp ./file /pfs/$DATACENTER/home/$USER/file
paddle pfs cp /pfs/$DATACENTER/home/$USER/file ./file
</pre></div>
</div>
<ul class="simple">
<li>ls- list files</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
ls [-r] &lt;PFSPath&gt; ...
Options:
-R
List directory(ies) recursively
Examples:
paddle pfs ls /pfs/$DATACENTER/home/$USER/file
paddle pfs ls /pfs/$DATACENTER/home/$USER/folder
</pre></div>
</div>
<ul class="simple">
<li>mkdir - mkdir directory(ies)
Create intermediate directory(ies) as required.</li>
</ul>
<div class="highlight-default"><div class="highlight"><pre><span></span>Synopsis:
mkdir &lt;PFSPath&gt; ...
Examples:
paddle pfs mkdir /pfs/$DATACENTER/home/$USER/folder
</pre></div>
</div>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<script type="text/javascript" src="../../../_static/translations.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>
<script type="text/javascript" src="../../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>构建Android平台上的PaddlePaddle库 &mdash; PaddlePaddle 文档</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../../genindex.html"/>
<link rel="search" title="搜索" href="../../search.html"/>
<link rel="top" title="PaddlePaddle 文档" href="../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="../index_cn.html">进阶指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/build_and_install/index_cn.html">安装与编译</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/docker_install_cn.html">PaddlePaddle的Docker容器使用方式</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/ubuntu_install_cn.html">Ubuntu部署PaddlePaddle</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/cmake/build_from_source_cn.html">PaddlePaddle的编译选项</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/concepts/use_concepts_cn.html">基本使用概念</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../index_cn.html">进阶指南</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../usage/cmd_parameter/index_cn.html">设置命令行参数</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../usage/cmd_parameter/use_case_cn.html">使用案例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../usage/cmd_parameter/arguments_cn.html">参数概述</a></li>
<li class="toctree-l3"><a class="reference internal" href="../usage/cmd_parameter/detail_introduction_cn.html">细节描述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../usage/cluster/cluster_train_cn.html">运行分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../usage/k8s/k8s_basis_cn.html">Kubernetes 简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="../usage/k8s/k8s_cn.html">Kubernetes单机训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../usage/k8s/k8s_distributed_cn.html">Kubernetes分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev/write_docs_cn.html">如何贡献/修改文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev/contribute_to_paddle_cn.html">如何贡献代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="../deep_model/rnn/index_cn.html">RNN相关模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../deep_model/rnn/recurrent_group_cn.html">Recurrent Group教程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../deep_model/rnn/hierarchical_layer_cn.html">支持双层序列作为输入的Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../deep_model/rnn/hrnn_rnn_api_compare_cn.html">单双层RNN API对比介绍</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../optimization/gpu_profiling_cn.html">GPU性能分析与调优</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/model_configs.html">模型配置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/data.html">数据访问</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/run_logic.html">训练与应用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>构建Android平台上的PaddlePaddle库</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="androidpaddlepaddle">
<span id="androidpaddlepaddle"></span><h1>构建Android平台上的PaddlePaddle库<a class="headerlink" href="#androidpaddlepaddle" title="永久链接至标题"></a></h1>
<p>用户可通过交叉编译的方式,在用户熟悉的开发平台(Linux,Mac OS X和Windows)上编译Android平台上适用的PaddlePaddle库。
本文档将以Linux x86-64平台为例,介绍交叉编译Android平台上适用的PaddlePaddle库的方法和步骤。</p>
<div class="section" id="">
<span id="id1"></span><h2>准备交叉编译环境<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>从源码交叉编译PaddlePaddle,用户需要提前准备好交叉编译环境。Android平台上使用的C/C++交叉编译工具链为<a class="reference external" href="https://developer.android.com/ndk/downloads/index.html?hl=zh-cn">Android NDK</a>,用户可自行前往下载预编译好的版本,也可通过以下命令获取:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>wget -q https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
unzip -q android-ndk-r14b-linux-x86_64.zip
</pre></div>
</div>
<p>Android NDK中包含了所有Android API级别、所有架构(arm/arm64/x86/mips)需要用到的编译工具和系统库。用户可根据自己的编译目标架构、所需支持的最低Android API级别,构建<a class="reference external" href="https://developer.android.google.cn/ndk/guides/standalone_toolchain.html?hl=zh-cn">独立工具链</a>
比如:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>your/path/to/android-ndk-r14b-linux-x86_64/build/tools/make-standalone-toolchain.sh <span class="se">\</span>
--arch<span class="o">=</span>arm --platform<span class="o">=</span>android-21 --install-dir<span class="o">=</span>your/path/to/my_standalone_toolchain
</pre></div>
</div>
<p>此命令将在your/path/to/my_standalone_toolchain目录生成一套编译工具链,面向架构为32位ARM架构,支持的最小的Android API级别为21,使用的编译器为arm-linux-androideabi-gcc (GCC) 4.9。</p>
<p>注意:<strong>PaddlePaddle要求使用的编译工具链所支持的Andoid API级别不小于21</strong></p>
</div>
<div class="section" id="">
<span id="id2"></span><h2>配置交叉编译参数<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>CMake系统对交叉编译提供了支持<a class="reference external" href="https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html#cross-compiling">cmake-toolchains</a>。为了简化cmake配置,PaddlePaddle为交叉编译提供了工具链配置文档<a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/cross_compiling/android.cmake">cmake/cross_compiling/android.cmake</a>,以提供一些默认的编译器和编译参数相关配置。注意,从CMake 3.7版本开始,CMake官方对Android平台的交叉编译提供了通用的支持。PaddlePaddle若检测到用户使用的CMake版本不低于3.7时,将会将用户传进来的配置参数传递CMake系统,交由CMake系统本身来处理。有关参数配置的详细说明见<a class="reference external" href="https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling">cmake-toolchains</a></p>
<p>交叉编译Android版本的PaddlePaddle库时,有一些必须配置的参数:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">CMAKE_SYSTEM_NAME</span></code>,CMake编译的目标平台,必须设置为<code class="docutils literal"><span class="pre">Android</span></code>。在设置<code class="docutils literal"><span class="pre">CMAKE_SYSTEM_NAME=Android</span></code>后,PaddlePaddle的CMake系统才认为是在交叉编译Android系统的版本,并自动编译宿主机版protoc可执行文件、目标机版protobuf库、以及Android所需<code class="docutils literal"><span class="pre">arm_soft_fp_abi</span></code>分支的目标机版OpenBLAS库。此外,还会强制设置一些PaddlePaddle参数的值(<code class="docutils literal"><span class="pre">WITH_GPU=OFF</span></code><code class="docutils literal"><span class="pre">WITH_AVX=OFF</span></code><code class="docutils literal"><span class="pre">WITH_PYTHON=OFF</span></code><code class="docutils literal"><span class="pre">WITH_RDMA=OFF</span></code>)。</li>
<li><code class="docutils literal"><span class="pre">WITH_C_API</span></code>,必须设置为<code class="docutils literal"><span class="pre">ON</span></code>。在Android平台上只支持使用C-API来预测。</li>
<li><code class="docutils literal"><span class="pre">WITH_SWIG_PY</span></code>,必须设置为<code class="docutils literal"><span class="pre">OFF</span></code>。在Android平台上不支持通过swig调用来训练或者预测。</li>
</ul>
<p>Android平台可选配置参数:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">ANDROID_STANDALONE_TOOLCHAIN</span></code>,独立工具链所在的绝对路径,或者相对于构建目录的相对路径。PaddlePaddle的CMake系统将根据该值自动推导和设置需要使用的交叉编译器、sysroot、以及Android API级别;否则,用户需要在cmake时手动设置这些值。无默认值。</li>
<li><code class="docutils literal"><span class="pre">ANDROID_ABI</span></code>,目标架构ABI。目前只支持<code class="docutils literal"><span class="pre">armeabi-v7a</span></code>,默认值为<code class="docutils literal"><span class="pre">armeabi-v7a</span></code></li>
<li><code class="docutils literal"><span class="pre">ANDROID_NATIVE_API_LEVEL</span></code>,工具链的Android API级别。若没有显式设置,PaddlePaddle将根据<code class="docutils literal"><span class="pre">ANDROID_STANDALONE_TOOLCHAIN</span></code>的值自动推导得到。</li>
<li><code class="docutils literal"><span class="pre">ANROID_ARM_MODE</span></code>,是否使用ARM模式。可设置<code class="docutils literal"><span class="pre">ON/OFF</span></code>,默认值为<code class="docutils literal"><span class="pre">ON</span></code></li>
<li><code class="docutils literal"><span class="pre">ANDROID_ARM_NEON</span></code>,是否使用NEON指令。目前必须设置成<code class="docutils literal"><span class="pre">ON</span></code>,默认值为<code class="docutils literal"><span class="pre">ON</span></code></li>
</ul>
<p>其他配置参数:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">HOST_C/CXX_COMPILER</span></code>,宿主机的C/C++编译器。在编译宿主机版protoc可执行文件和目标机版OpenBLAS库时需要用到。默认设置成环境变量<code class="docutils literal"><span class="pre">CC</span></code>的值;若环境变量<code class="docutils literal"><span class="pre">CC</span></code>没有设置,则设置成<code class="docutils literal"><span class="pre">cc</span></code>编译器。</li>
</ul>
<p>一种常用的cmake配置如下:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -DCMAKE_SYSTEM_NAME<span class="o">=</span>Android <span class="se">\</span>
-DANDROID_STANDALONE_TOOLCHAIN<span class="o">=</span>your/path/to/my_standalone_toolchain <span class="se">\</span>
-DANDROID_ABI<span class="o">=</span>armeabi-v7a <span class="se">\</span>
-DANDROID_ARM_NEON<span class="o">=</span>ON <span class="se">\</span>
-DANDROID_ARM_MODE<span class="o">=</span>ON <span class="se">\</span>
-DCMAKE_INSTALL_PREFIX<span class="o">=</span>your/path/to/install <span class="se">\</span>
-DWITH_C_API<span class="o">=</span>ON <span class="se">\</span>
-DWITH_SWIG_PY<span class="o">=</span>OFF <span class="se">\</span>
..
</pre></div>
</div>
<p>用户还可根据自己的需求设置其他编译参数。比如希望最小化生成的库的大小,可以设置<code class="docutils literal"><span class="pre">CMAKE_BUILD_TYPE</span></code><code class="docutils literal"><span class="pre">MinSizeRel</span></code>;若希望最快的执行速度,则可设置<code class="docutils literal"><span class="pre">CMAKE_BUILD_TYPE</span></code><code class="docutils literal"><span class="pre">Release</span></code>。亦可以通过手动设置<code class="docutils literal"><span class="pre">CMAKE_C/CXX_FLAGS_MINSIZEREL/RELEASE</span></code>来影响PaddlePaddle的编译过程。</p>
</div>
<div class="section" id="">
<span id="id3"></span><h2>编译和安装<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>CMake配置完成后,执行以下命令,PaddlePaddle将自动下载和编译所有第三方依赖库、编译和安装PaddlePaddle预测库。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>make
make install
</pre></div>
</div>
<p>注意:如果你曾经在源码目录下编译过其他平台的PaddlePaddle库,请先使用<code class="docutils literal"><span class="pre">rm</span> <span class="pre">-rf</span></code>命令删除<code class="docutils literal"><span class="pre">third_party</span></code>目录和<code class="docutils literal"><span class="pre">build</span></code>目录,以确保所有的第三方依赖库和PaddlePaddle代码都是针对新的CMake配置重新编译的。</p>
<p>执行完安装命令后,<code class="docutils literal"><span class="pre">your/path/to/install</span></code>目录中会包含<code class="docutils literal"><span class="pre">include</span></code><code class="docutils literal"><span class="pre">lib</span></code>目录,其中<code class="docutils literal"><span class="pre">include</span></code>中包含C-API的头文件,<code class="docutils literal"><span class="pre">lib</span></code>中包含一个Android版本的库。自此,PaddlePaddle的已经安装完成,用户可将<code class="docutils literal"><span class="pre">your/path/to/install</span></code>目录下的生成文件用于深度学习相关Android App中,调用方法见C-API文档。</p>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/translations.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>构建Raspberry Pi平台上的PaddlePaddle库 &mdash; PaddlePaddle 文档</title>
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="index" title="索引"
href="../../genindex.html"/>
<link rel="search" title="搜索" href="../../search.html"/>
<link rel="top" title="PaddlePaddle 文档" href="../../index.html"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/override.css" type="text/css" />
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?b9a314ab40d04d805655aab1deee08ba";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<script src="../../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<header class="site-header">
<div class="site-logo">
<a href="/"><img src="../../_static/images/PP_w.png"></a>
</div>
<div class="site-nav-links">
<div class="site-menu">
<a class="fork-on-github" href="https://github.com/PaddlePaddle/Paddle" target="_blank"><i class="fa fa-github"></i>Folk me on Github</a>
<div class="language-switcher dropdown">
<a type="button" data-toggle="dropdown">
<span>English</span>
<i class="fa fa-angle-up"></i>
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu">
<li><a href="/doc_cn">中文</a></li>
<li><a href="/doc">English</a></li>
</ul>
</div>
<ul class="site-page-links">
<li><a href="/">Home</a></li>
</ul>
</div>
<div class="doc-module">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="../index_cn.html">进阶指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
</header>
<div class="main-content-wrap">
<nav class="doc-menu-vertical" role="navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getstarted/index_cn.html">新手入门</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/build_and_install/index_cn.html">安装与编译</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/docker_install_cn.html">PaddlePaddle的Docker容器使用方式</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/ubuntu_install_cn.html">Ubuntu部署PaddlePaddle</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../getstarted/build_and_install/cmake/build_from_source_cn.html">PaddlePaddle的编译选项</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../getstarted/concepts/use_concepts_cn.html">基本使用概念</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../index_cn.html">进阶指南</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../usage/cmd_parameter/index_cn.html">设置命令行参数</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../usage/cmd_parameter/use_case_cn.html">使用案例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../usage/cmd_parameter/arguments_cn.html">参数概述</a></li>
<li class="toctree-l3"><a class="reference internal" href="../usage/cmd_parameter/detail_introduction_cn.html">细节描述</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../usage/cluster/cluster_train_cn.html">运行分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../usage/k8s/k8s_basis_cn.html">Kubernetes 简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="../usage/k8s/k8s_cn.html">Kubernetes单机训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../usage/k8s/k8s_distributed_cn.html">Kubernetes分布式训练</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev/write_docs_cn.html">如何贡献/修改文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev/contribute_to_paddle_cn.html">如何贡献代码</a></li>
<li class="toctree-l2"><a class="reference internal" href="../deep_model/rnn/index_cn.html">RNN相关模型</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../deep_model/rnn/recurrent_group_cn.html">Recurrent Group教程</a></li>
<li class="toctree-l3"><a class="reference internal" href="../deep_model/rnn/hierarchical_layer_cn.html">支持双层序列作为输入的Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../deep_model/rnn/hrnn_rnn_api_compare_cn.html">单双层RNN API对比介绍</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../optimization/gpu_profiling_cn.html">GPU性能分析与调优</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../api/index_cn.html">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/model_configs.html">模型配置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/activation.html">Activation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/layer.html">Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/evaluators.html">Evaluators</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/optimizer.html">Optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/pooling.html">Pooling</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/networks.html">Networks</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../api/v2/config/attr.html">Parameter Attribute</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/data.html">数据访问</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/v2/run_logic.html">训练与应用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index_cn.html">FAQ</a></li>
</ul>
</nav>
<section class="doc-content-wrap">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li>构建Raspberry Pi平台上的PaddlePaddle库</li>
</ul>
</div>
<div class="wy-nav-content" id="doc-content">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="raspberry-pipaddlepaddle">
<span id="raspberry-pipaddlepaddle"></span><h1>构建Raspberry Pi平台上的PaddlePaddle库<a class="headerlink" href="#raspberry-pipaddlepaddle" title="永久链接至标题"></a></h1>
<p>对于Rasspberry Pi系统,用户可通过ssh等方式登录到Raspberry Pi系统上,按照<a class="reference external" href="http://www.paddlepaddle.org/doc_cn/getstarted/build_and_install/cmake/build_from_source_cn.html">源码编译PaddlePaddle</a>相关文档所述,直接编译Raspberry Pi平台上适用的PaddlePaddle库。</p>
<p>用户也可以在自己熟悉的开发平台上,通过交叉编译的方式来编译。这篇文档将以Linux x86-64平台为例,介绍交叉编译Raspberry Pi平台上适用的PaddlePaddle的方法和步骤。</p>
<div class="section" id="">
<span id="id1"></span><h2>准备交叉编译环境<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>从源码交叉编译PaddlePaddle,用户需要提前准备好交叉编译环境。用户可自行前往<a class="reference external" href="https://github.com/raspberrypi/tools">github</a>下载Raspberry Pi平台使用的C/C++交叉编译工具链,也可通过以下命令获取:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>git clone https://github.com/raspberrypi/tools.git
</pre></div>
</div>
<p>该github仓库中包含若干个预编译好的、针对不同平台的编译工具。宿主机是Linux x86-64环境,则需选用<code class="docutils literal"><span class="pre">arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64</span></code>下的作为编译工具,所使用的编译器为arm-linux-gnueabihf-gcc 4.8.3。</p>
<p>注意,该编译工具链需要系统glibc支持2.14以上。</p>
</div>
<div class="section" id="">
<span id="id2"></span><h2>配置交叉编译参数<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>CMake系统对交叉编译提供了支持<a class="reference external" href="https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html#cross-compiling">cmake-toolchains</a>。为了简化cmake配置,PaddlePaddle为交叉编译提供了工具链配置文档<a class="reference external" href="https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/cross_compiling/raspberry_pi.cmake">cmake/cross_compiling/raspberry_pi.cmake</a>,以提供一些默认的编译器和编译参数相关配置。</p>
<p>交叉编译Raspberry Pi版本PaddlePaddle库时,有一些必须配置的参数:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">CMAKE_SYSTEM_NAME</span></code>,CMake编译的目标平台,必须配置为<code class="docutils literal"><span class="pre">RPi</span></code>。在设置<code class="docutils literal"><span class="pre">CMAKE_SYSTEM_NAME=RPi</span></code>后,PaddlePaddle的CMake系统才认为在是在交叉编译Raspberry Pi系统的版本,并自动编译宿主机版protoc可执行文件、目标机版protobuf库、以及目标机版OpenBLAS库。</li>
</ul>
<p>Raspberry Pi平台可选配置参数:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">RPI_TOOLCHAIN</span></code>,编译工具链所在的绝对路径,或者相对于构建目录的相对路径。PaddlePaddle的CMake系统将根据该值自动设置需要使用的交叉编译器;否则,用户需要在cmake时手动设置这些值。无默认值。</li>
<li><code class="docutils literal"><span class="pre">RPI_ARM_NEON</span></code>,是否使用NEON指令。目前必须设置成<code class="docutils literal"><span class="pre">ON</span></code>,默认值为<code class="docutils literal"><span class="pre">ON</span></code></li>
</ul>
<p>其他配置参数:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">HOST_C/CXX_COMPILER</span></code>,宿主机的C/C++编译器。在编译宿主机版protoc可执行文件和目标机版OpenBLAS库时需要用到。默认设置成环境变量<code class="docutils literal"><span class="pre">CC</span></code>的值;若环境变量<code class="docutils literal"><span class="pre">CC</span></code>没有设置,则设置成<code class="docutils literal"><span class="pre">cc</span></code>编译器。</li>
</ul>
<p>cmake参数如下;</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">cmake</span> <span class="o">-</span><span class="n">DCMAKE_SYSTEM_NAME</span><span class="o">=</span><span class="n">RPi</span> \
<span class="o">-</span><span class="n">DRPI_TOOLCHAIN</span><span class="o">=</span><span class="n">your</span><span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">arm</span><span class="o">-</span><span class="n">bcm2708</span><span class="o">/</span><span class="n">gcc</span><span class="o">-</span><span class="n">linaro</span><span class="o">-</span><span class="n">arm</span><span class="o">-</span><span class="n">linux</span><span class="o">-</span><span class="n">gnueabihf</span><span class="o">-</span><span class="n">raspbian</span><span class="o">-</span><span class="n">x64</span> \
<span class="o">-</span><span class="n">DRPI_ARM_NEON</span><span class="o">=</span><span class="n">ON</span> \
<span class="o">-</span><span class="n">DCMAKE_INSTALL_PREFIX</span><span class="o">=</span><span class="n">your</span><span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">install</span> \
<span class="o">-</span><span class="n">DWITH_GPU</span><span class="o">=</span><span class="n">OFF</span> \
<span class="o">-</span><span class="n">DWITH_C_API</span><span class="o">=</span><span class="n">ON</span> \
<span class="o">-</span><span class="n">DWITH_PYTHON</span><span class="o">=</span><span class="n">OFF</span> \
<span class="o">-</span><span class="n">DWITH_SWIG_PY</span><span class="o">=</span><span class="n">OFF</span> \
<span class="o">..</span>
</pre></div>
</div>
<p>用户还可根据自己的需求设置其他编译参数。比如希望最小化生成的库的大小,可以设置<code class="docutils literal"><span class="pre">CMAKE_BUILD_TYPE</span></code><code class="docutils literal"><span class="pre">MinSizeRel</span></code>;若希望最快的执行速度,则可设置<code class="docutils literal"><span class="pre">CMAKE_BUILD_TYPE</span></code><code class="docutils literal"><span class="pre">Release</span></code>。亦可以通过手动设置<code class="docutils literal"><span class="pre">CMAKE_C/CXX_FLAGS_MINSIZEREL/RELEASE</span></code>来影响PaddlePaddle的编译过程。</p>
</div>
<div class="section" id="">
<span id="id3"></span><h2>编译和安装<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>CMake配置完成后,执行以下命令,PaddlePaddle将自动下载和编译所有第三方依赖库、编译和安装PaddlePaddle。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>make
make install
</pre></div>
</div>
<p>注意:如果你曾经在源码目录下编译过其他平台的PaddlePaddle库,请先使用<code class="docutils literal"><span class="pre">rm</span> <span class="pre">-rf</span></code>命令删除<code class="docutils literal"><span class="pre">third_party</span></code>目录和<code class="docutils literal"><span class="pre">build</span></code>目录,以确保所有的第三方依赖库和PaddlePaddle代码都是针对新的CMake配置重新编译的。</p>
<p>执行完安装命令后,由于上一步cmake配置中<code class="docutils literal"><span class="pre">WITH_C_API</span></code>设置为<code class="docutils literal"><span class="pre">ON</span></code><code class="docutils literal"><span class="pre">your/path/to/install</span></code>目录中会包含<code class="docutils literal"><span class="pre">include</span></code><code class="docutils literal"><span class="pre">lib</span></code>目录,其中<code class="docutils literal"><span class="pre">include</span></code>中包含C-API的头文件,<code class="docutils literal"><span class="pre">lib</span></code>中包含一个Raspberry Pi版本的库。</p>
<p>更多的编译配置见<a class="reference external" href="http://www.paddlepaddle.org/doc_cn/getstarted/build_and_install/cmake/build_from_source_cn.html">源码编译PaddlePaddle</a>相关文档。</p>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016, PaddlePaddle developers.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ".txt",
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<script type="text/javascript" src="../../_static/translations.js"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.0/MathJax.js"></script>
<script type="text/javascript" src="../../_static/js/theme.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/js/perfect-scrollbar.jquery.min.js"></script>
<script src="../../_static/js/paddle_doc_init.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -262,7 +262,7 @@
</div>
<div class="section" id="expand">
<h2><a class="toc-backref" href="#id6">expand</a><a class="headerlink" href="#expand" title="永久链接至标题"></a></h2>
<p>expand 的使用示例如下,详细见 <a class="reference internal" href="../../../api/v2/config/layer.html#api-v2-layer-expand"><span class="std std-ref">expand</span></a> 配置API。</p>
<p>expand 的使用示例如下,详细见 <a class="reference internal" href="../../../api/v2/config/layer.html#api-v2-layer-expand"><span class="std std-ref">ExpandLevel</span></a> 配置API。</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nv">ex</span> <span class="o">=</span> expand<span class="o">(</span><span class="nv">input</span><span class="o">=</span>layer1,
<span class="nv">expand_as</span><span class="o">=</span>layer2,
<span class="nv">expand_level</span><span class="o">=</span>ExpandLevel.FROM_TIMESTEP<span class="o">)</span>
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册