Skip to content

Commit 8e6965b

Browse files
author
Yi Wang
committed
Resolve conflict with upstream/develop
2 parents bb13328 + 257819d commit 8e6965b

File tree

14 files changed

+339
-58
lines changed

14 files changed

+339
-58
lines changed

doc_cn/build/docker/build_docker_image.rst

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
构建PaddlePaddle的Docker Image
2+
==============================
3+
PaddlePaddle的Docker Image构建源码放置在 ``${源码根目录}/paddle/scripts/docker/`` 目录下。该目录有三类文件:
4+
5+
- Dockerfile:Docker Image的描述文件,包括构建步骤、各种参数和维护人员等。
6+
7+
- 一共维护了12个Dockerfile,Dockerfile.m4是它们的模板。
8+
- PaddlePaddle中所有的Image都基于ubuntu 14.04。
9+
10+
- build.sh:Docker Image的构建脚本,使用方式见下一小节。
11+
- generate.sh:通过Dockerfile.m4模板生成不同的Dockerfile。
12+
13+
使用脚本构建Docker Image
14+
------------------------
15+
16+
进入源码目录,执行 ``docker build`` 命令,即可在本地编译出PaddlePaddle的镜像。简单的使用样例为
17+
18+
.. code-block:: bash
19+
20+
cd ${源码根目录}/paddle/scripts/docker/
21+
docker build --build-arg LOWEST_DL_SPEED=50K\
22+
--build-arg WITH_GPU=ON \
23+
--tag paddle_gpu:latest .
24+
25+
其中,``--build-arg`` 传入的配置参数包括:
26+
27+
- LOWEST\_DL\_SPEED\: 在多线程下载过程中,设置下线线程的最低速度。
28+
29+
- 默认单位是Bytes,但可以传入10K、10M、或10G等这样的单位。
30+
- 如果小于这个速度,那么这个线程将会关闭。当所有的线程都关闭了,那么下载进程将会重启。
31+
- WITH\_GPU\: ON or OFF,是否开启GPU功能。注意,
32+
- **编译** PaddlePaddle的GPU版本 **不一定** 要在具有GPU的机器上进行。
33+
- **运行** PaddlePaddle的GPU版本 **一定** 要在具有GPU的机器上运行。
34+
35+
注意:所有Image的构建在Docker 1.12版本测试通过, 低于1.12的版本并没有测试。原因是旧版本可能缺乏 ``--build-arg`` 参数,从而不能在运行编译命令的时候接受参数。

doc_cn/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PaddlePaddle文档
1616
--------
1717
* `新写Layer <../doc/dev/new_layer/index.html>`_
1818
* `如何贡献文档 <howto/how_to_write_docs/index.html>`_
19+
* `如何构建Docker Image <howto/build_docker_image.html>`_
1920

2021
算法教程
2122
--------

paddle/gserver/layers/ConvProjection.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ void ConvProjection::getConvParams() {
5959

6060
void ConvProjection::initCudnn() {
6161
hl_create_filter_descriptor(
62-
&filterDesc_, channels_, numFilters_, filterH_, filterW_);
62+
&filterDesc_, channels_ / groups_, numFilters_ / groups_,
63+
filterH_, filterW_);
6364
hl_create_tensor_descriptor(&inputDesc_);
6465
hl_create_tensor_descriptor(&outputDesc_);
6566
hl_create_convolution_descriptor(&convDesc_,
@@ -86,7 +87,7 @@ void ConvProjection::initCudnn() {
8687
void ConvProjection::reshapeTensorDesc(int batchSize) {
8788
hl_tensor_reshape(inputDesc_,
8889
batchSize,
89-
channels_,
90+
channels_ / groups_,
9091
imageH_,
9192
imageW_,
9293
channels_ * imageH_ * imageW_,
@@ -115,7 +116,7 @@ void ConvProjection::reshapeTensorDesc(int batchSize) {
115116

116117
hl_tensor_reshape(outputDesc_,
117118
batchSize,
118-
numFilters_,
119+
numFilters_ / groups_,
119120
outputH_,
120121
outputW_,
121122
nStride,

paddle/gserver/layers/ExpandConvBaseLayer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void ExpandConvBaseLayer::expandFwdOnce(MatrixPtr image,
145145
real *expInData = expandInput_->getData();
146146
for (int g = 0; g < groups_[inIdx]; ++g) {
147147
MatrixPtr A =
148-
Matrix::create(wgtData, subK, subM, true, useGpu_); // mark transpose
148+
Matrix::create(wgtData, subM, subK, false, useGpu_); // mark transpose
149149
MatrixPtr B = Matrix::create(expInData, subK, subN, false, useGpu_);
150150
MatrixPtr C = Matrix::create(outData, subM, subN, false, useGpu_);
151151
C->mul(A, B, 1, 1);
@@ -182,7 +182,7 @@ void ExpandConvBaseLayer::bpropActs(MatrixPtr out,
182182
// create temporary matrix
183183
MatrixPtr C = Matrix::create(expandInData, subK, subN, false, useGpu_);
184184
MatrixPtr B = Matrix::create(localGradData, subM, subN, false, useGpu_);
185-
MatrixPtr A = Matrix::create(wgtData, subK, subM, false, useGpu_);
185+
MatrixPtr A = Matrix::create(wgtData, subM, subK, true, useGpu_);
186186
C->mul(A, B); // mul
187187

188188
// clear the temporary matrix
@@ -247,10 +247,10 @@ void ExpandConvBaseLayer::bpropWeights(MatrixPtr image,
247247

248248
// expand-mul one-group by one
249249
for (int g = 0; g < groups_[inpIdx]; g++) {
250-
MatrixPtr A = Matrix::create(expandInData, subK, subN, false, useGpu_);
251-
MatrixPtr B = Matrix::create(gradData, subM, subN, true, useGpu_);
252-
MatrixPtr C = Matrix::create(wGradData, subK, subM, false, useGpu_);
253-
C->mul(A, B, 1, 1);
250+
MatrixPtr A = Matrix::create(expandInData, subK, subN, true, useGpu_);
251+
MatrixPtr B = Matrix::create(gradData, subM, subN, false, useGpu_);
252+
MatrixPtr C = Matrix::create(wGradData, subM, subK, false, useGpu_);
253+
C->mul(B, A, 1, 1);
254254

255255
A->clear();
256256
B->clear();

paddle/gserver/tests/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ add_unittest_without_exec(test_ConvTrans
3434

3535
add_test(NAME test_ConvTrans
3636
COMMAND test_ConvTrans)
37+
################# test_ConvUnify #######################
38+
add_unittest_without_exec(test_ConvUnify
39+
test_ConvUnify.cpp
40+
LayerGradUtil.cpp
41+
TestUtil.cpp)
3742

43+
add_test(NAME test_ConvUnify
44+
COMMAND test_ConvUnify)
3845
################## test_Evaluator #######################
3946
add_unittest(test_Evaluator
4047
test_Evaluator.cpp

paddle/gserver/tests/img_conv_a.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ conv = img_conv_layer(input=data, filter_size=1, filter_size_y=1,
3434
num_channels=8,
3535
num_filters=16, stride=1,
3636
bias_attr=True,
37-
act=LinearActivation())
37+
act=LinearActivation(),
38+
groups=2)
3839

3940
outputs(concat, conv)

paddle/gserver/tests/img_conv_b.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ proj2 = conv_projection(input=data, filter_size=1, filter_size_y=1,
2424
concat = concat_layer(input=[proj1, proj2], bias_attr=False, act=ReluActivation())
2525

2626
proj = conv_projection(input=data, filter_size=1, filter_size_y=1,
27-
num_channels=8, num_filters=16, stride=1)
27+
num_channels=8, num_filters=16, stride=1, groups=2)
2828

2929
with mixed_layer(bias_attr=True, act=LinearActivation()) as conv:
3030
conv += proj
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#edit-mode: -*- python -*-
2+
# Copyright (c) 2016 Baidu, Inc. All Rights Reserved
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
from paddle.trainer_config_helpers import *
17+
18+
settings(batch_size=10)
19+
data = data_layer(name ="input", size=8*16*16)
20+
conv1 = img_conv_layer(input=data, filter_size=1, filter_size_y=1,
21+
num_channels=8,
22+
num_filters=16, stride=1,
23+
bias_attr=False,
24+
act=ReluActivation(),
25+
layer_type="exconv")
26+
conv2 = img_conv_layer(input=data, filter_size=1, filter_size_y=1,
27+
num_channels=8,
28+
num_filters=16, stride=1,
29+
bias_attr=False,
30+
act=ReluActivation(),
31+
layer_type="exconv")
32+
33+
concat = concat_layer(input=[conv1, conv2])
34+
35+
conv = img_conv_layer(input=data, filter_size=1, filter_size_y=1,
36+
num_channels=8,
37+
num_filters=16, stride=1,
38+
bias_attr=True,
39+
act=LinearActivation(),
40+
groups=2,
41+
layer_type="exconv")
42+
43+
outputs(concat, conv)

0 commit comments

Comments
 (0)