Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions doc/getstarted/build_and_install/build_from_source_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
从源码编译PaddlePaddle
======================

.. _build_step:

编译方法
----------------

PaddlePaddle主要使用 `CMake <https://cmake.org>`_ 以及GCC, G++作为编译工具。
我们推荐您使用PaddlePaddle编译环境镜像完成编译,这样可以免去单独安装编译依赖的步骤,可选的不同编译环境
可以在 `这里 <https://hub.docker.com/r/paddlepaddle/paddle_manylinux_devel/tags/>`_ 找到。
编译PaddlePaddle,需要执行:

.. code-block:: bash

git clone https://github.com/PaddlePaddle/Paddle.git
cd Paddle
# 如果使用Docker编译环境,执行下面的命令
docker run -it -v $PWD:/paddle -e "WITH_GPU=ON" -e "WITH_TESTING=OFF" paddlepaddle/paddle_manylinux_devel:cuda8.0_cudnn5 bash -x paddle/scripts/docker/build.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

示例中WITH_GPU=OFF会不会好一点, 23行也是。或者说明一下?

# 如果不使用Docker编译环境,执行下面的命令
mkdir build
cd build
cmake -DWITH_GPU=ON -DWITH_TESTING=OFF ..
make


编译完成后会在build/python/dist目录下生成输出的whl包,可以选在在当前机器安装也可以拷贝到目标机器安装:

.. code-block:: bash

pip install python/dist/*.whl


.. _build_step:

编译依赖
----------------

PaddlePaddle编译需要使用到下面的依赖(包含但不限于),其他的依赖软件,会自动在编译时下载。

.. csv-table:: PaddlePaddle编译依赖
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
表格的标题是斜体?不过可以等merge进整体网站的时候看看标题是否还是斜体。

:header: "依赖", "版本", "说明"
:widths: 10, 15, 30

"CMake", ">=3.5", ""
"GCC", "4.8.2", "推荐使用CentOS的devtools2"
"Python", "2.7.x", "依赖libpython2.7.so"
"pip", ">=9.0", ""
"numpy", "", ""
"SWIG", ">=2.0", ""
"Go", ">=1.8", "可选"


.. _build_options:

编译选项
----------------

PaddlePaddle的编译选项,包括生成CPU/GPU二进制文件、链接何种BLAS库等。用户可在调用cmake的时候设置它们,详细的cmake使用方法可以参考 `官方文档 <https://cmake.org/cmake-tutorial>`_ 。

.. _build_options_bool:

Bool型的编译选项
----------------

用户可在cmake的命令行中,通过使用 ``-D`` 命令设置该类编译选项,例如

.. code-block:: bash

cmake .. -DWITH_GPU=OFF

.. csv-table:: Bool型的编译选项
:header: "选项", "说明", "默认值"
:widths: 1, 7, 2

"WITH_GPU", "是否支持GPU。", "是"
"WITH_DOUBLE", "是否使用双精度浮点数。", "否"
"WITH_DSO", "是否运行时动态加载CUDA动态库,而非静态加载CUDA动态库。", "是"
"WITH_AVX", "是否编译含有AVX指令集的PaddlePaddle二进制文件", "是"
"WITH_PYTHON", "是否内嵌PYTHON解释器。", "是"
"WITH_STYLE_CHECK", "是否编译时进行代码风格检查", "是"
"WITH_TESTING", "是否开启单元测试", "是"
"WITH_DOC", "是否编译中英文文档", "否"
"WITH_SWIG_PY", "是否编译PYTHON的SWIG接口,该接口可用于预测和定制化训练", "自动"
"WITH_GOLANG", "是否编译go语言的可容错parameter server", "是"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“是“ -> ON, “否”-> OFF?


.. _build_options_blas:

BLAS/CUDA/Cudnn的编译选项
--------------------------
BLAS
+++++

PaddlePaddle支持以下任意一种BLAS库:`MKL <https://software.intel.com/en-us/intel-mkl>`_ ,`ATLAS <http://math-atlas.sourceforge.net/>`_ ,`OpenBlAS <http://www.openblas.net/>`_ 和 `REFERENCE BLAS <http://www.netlib.org/blas/>`_ 。

.. csv-table:: BLAS路径相关的编译选项
:header: "编译选项", "描述", "注意"
:widths: 1, 2, 7

"MKL_ROOT", "${MKL_ROOT}/include下需要包含mkl.h,${MKL_ROOT}/lib目录下需要包含mkl_core,mkl_sequential和mkl_intel_lp64三个库。"
"ATLAS_ROOT", "${ATLAS_ROOT}/include下需要包含cblas.h,${ATLAS_ROOT}/lib下需要包含cblas和atlas两个库。"
"OPENBLAS_ROOT", "${OPENBLAS_ROOT}/include下需要包含cblas.h,${OPENBLAS_ROOT}/lib下需要包含openblas库。"
"REFERENCE_CBLAS_ROOT", "${REFERENCE_CBLAS_ROOT}/include下需要包含cblas.h,${REFERENCE_CBLAS_ROOT}/lib下需要包含cblas库。"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在这些ROOT都不用用户自己指定了,OpenBlas和MKL都是自动下载第三方库。

编译选项:"WITH_MKL", "是否使用MKL数学库", "是"
否的时候:使用OpenBlas数学库。

如果机器含有AVX2指令集,还会下载MKL-DNN数学库,文档:https://github.com/PaddlePaddle/Paddle/tree/develop/doc/design/mkldnn#cmake

可以再组织一下。

@Xreki @hedaoyuan ATLAS是不是可以删了?


CUDA/Cudnn
+++++++++++

PaddlePaddle可以使用cudnn v2之后的任何一个版本来编译运行,但尽量请保持编译和运行使用的cudnn是同一个版本。 我们推荐使用最新版本的cudnn v5.1。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PaddlePaddle可以使用cudnn v2之后的任何一个版本来编译运行

现在必须使用V5.1 @qingqing01 这块还有什么其他需要注意的地方么

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cudnn -> cuDNN, 要求最低v5.1吧,其他应该没了。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CUDA加下 CUDA_ARCH_NAME参数,提醒开发者-DCUDA_ARCH_NAME=Auto可以加速编译吧。


编译选项的设置
++++++++++++++

PaddePaddle通过编译时指定路径来实现引用各种BLAS/CUDA/Cudnn库。cmake编译时,首先在系统路径(/usr/lib\:/usr/local/lib)中搜索这几个库,同时也会读取相关路径变量来进行搜索。 通过使用 ``-D`` 命令可以设置,例如

.. code-block:: bash

cmake .. -DMKL_ROOT=/opt/mkl/ -DCUDNN_ROOT=/opt/cudnnv5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-DMKL_ROOT=/opt/mkl/ 这个可以去掉,用户不用设置了。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只保留了MKL和OpenBLAS,我看cmake中其他的已经没在使用了。


注意:这几个编译选项的设置,只在第一次cmake的时候有效。如果之后想要重新设置,推荐清理整个编译目录(``rm -rf``)后,再指定。
236 changes: 0 additions & 236 deletions doc/getstarted/build_and_install/build_from_source_en.md

This file was deleted.

Loading