Skip to content

Commit f054867

Browse files
authored
Get rid of the dependency of Go compiler when WITH_GOLANG is OFF. (#8610)
* Get rid of the dependency of Go compiler when WITH_GOLANG is OFF. * Minor modification to the documentation. * Remove the downloading and installing of Go compiler when build developing Docker image for android. * Minor modifcation to the documentation's format. * Change the default value of WITH_GOLANG to OFF in paddle/scripts/docker/build.sh.
1 parent 00595f7 commit f054867

File tree

8 files changed

+42
-35
lines changed

8 files changed

+42
-35
lines changed

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set(PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1919

2020
include(system)
2121

22-
project(paddle CXX C Go)
22+
project(paddle CXX C)
2323
message(STATUS "CXX compiler: ${CMAKE_CXX_COMPILER}, version: "
2424
"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
2525
message(STATUS "C compiler: ${CMAKE_C_COMPILER}, version: "
@@ -175,7 +175,7 @@ set(EXTERNAL_LIBS
175175
)
176176

177177
if(WITH_GPU)
178-
include(cuda)
178+
include(cuda)
179179
endif(WITH_GPU)
180180

181181
if(WITH_MKLML)
@@ -202,17 +202,18 @@ endif()
202202
# "add_subdirectory(paddle)" and "add_subdirectory(python)" should be
203203
# placed after this block, because they depends on it.
204204
if(WITH_GOLANG)
205+
enable_language(Go)
205206
add_subdirectory(go)
206207
endif(WITH_GOLANG)
207208

208209
set(PADDLE_PYTHON_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/python/build")
209210

210-
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
211-
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
211+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
212+
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
212213

213214
add_subdirectory(paddle)
214215
if(WITH_PYTHON)
215-
add_subdirectory(python)
216+
add_subdirectory(python)
216217
endif()
217218

218219
if(WITH_DOC)

Dockerfile.android

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ RUN apt-get update && \
2121
wget curl tar unzip gcc g++ locales clang-format-3.8 swig cmake && \
2222
apt-get clean -y
2323

24-
# Install Go and glide
25-
RUN wget -qO- go.tgz https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz | \
26-
tar -xz -C /usr/local && \
27-
mkdir /root/gopath && \
28-
mkdir /root/gopath/bin && \
29-
mkdir /root/gopath/src
30-
ENV GOROOT=/usr/local/go GOPATH=/root/gopath
31-
# should not be in the same line with GOROOT definition, otherwise docker build could not find GOROOT.
32-
ENV PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
33-
3424
# git credential to skip password typing
3525
RUN git config --global credential.helper store
3626

doc/build_and_install/build_from_source_cn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ PaddlePaddle的编译选项,包括生成CPU/GPU二进制文件、链接何种B
189189
"WITH_TESTING", "是否开启单元测试", "OFF"
190190
"WITH_DOC", "是否编译中英文文档", "OFF"
191191
"WITH_SWIG_PY", "是否编译PYTHON的SWIG接口,该接口可用于预测和定制化训练", "Auto"
192-
"WITH_GOLANG", "是否编译go语言的可容错parameter server", "ON"
192+
"WITH_GOLANG", "是否编译go语言的可容错parameter server", "OFF"
193193
"WITH_MKL", "是否使用MKL数学库,如果为否则是用OpenBLAS", "ON"
194194

195195
BLAS

doc/build_and_install/build_from_source_en.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ You can add :code:`-D` argument to pass such options, like:
191191
"WITH_TESTING", "Build unit tests", "OFF"
192192
"WITH_DOC", "Build documentations", "OFF"
193193
"WITH_SWIG_PY", "Build Python SWIG interface for V2 API", "Auto"
194-
"WITH_GOLANG", "Build fault-tolerant parameter server written in go", "ON"
194+
"WITH_GOLANG", "Build fault-tolerant parameter server written in go", "OFF"
195195
"WITH_MKL", "Use MKL as BLAS library, else use OpenBLAS", "ON"
196196

197197

doc/mobile/cross_compiling_for_android_cn.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ $ docker build -t username/paddle-android:dev . -f Dockerfile.android
2323
$ docker pull paddlepaddle/paddle:latest-dev-android
2424
```
2525

26+
对于国内用户,我们提供了加速访问的镜像源:
27+
28+
```bash
29+
$ docker pull docker.paddlepaddlehub.com/paddle:latest-dev-android
30+
```
31+
2632
### 编译PaddlePaddle C-API库
2733
构建好开发镜像后,即可使用开发镜像来编译Android版PaddlePaddle C-API库。
2834
Android的Docker开发镜像向用户提供两个可配置的参数:
@@ -56,15 +62,15 @@ Android的Docker开发镜像向用户提供两个可配置的参数:
5662

5763
- 编译`armeabi-v7a``Android API 21`的PaddlePaddle库
5864

59-
```bash
60-
$ docker run -it --rm -v $PWD:/paddle -e "ANDROID_ABI=armeabi-v7a" -e "ANDROID_API=21" username/paddle-android:dev
61-
```
65+
```bash
66+
$ docker run -it --rm -v $PWD:/paddle -e "ANDROID_ABI=armeabi-v7a" -e "ANDROID_API=21" username/paddle-android:dev
67+
```
6268

6369
- 编译`arm64-v8a``Android API 21`的PaddlePaddle库
6470

65-
```bash
66-
$ docker run -it --rm -v $PWD:/paddle -e "ANDROID_ABI=arm64-v8a" -e "ANDROID_API=21" username/paddle-android:dev
67-
```
71+
```bash
72+
$ docker run -it --rm -v $PWD:/paddle -e "ANDROID_ABI=arm64-v8a" -e "ANDROID_API=21" username/paddle-android:dev
73+
```
6874

6975
执行上述`docker run`命令时,容器默认执行[paddle/scripts/docker/build_android.sh](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build_android.sh)脚本。该脚本中记录了交叉编译Android版PaddlePaddle库常用的CMake配置,并且会根据`ANDROID_ABI``ANDROID_API`自动构建独立工具链、进行编译和安装。由于arm64架构要求Android API不小于21。因此当`ANDROID_ABI=arm64-v8a``ANDROID_API<21`时,Docker容器中将默认使用`Android API 21`的编译工具链。用户可以参考下文[配置交叉编译参数](#配置交叉编译参数)章节,根据个人的需求修改定制Docker容器所执行的脚本。编译安装结束之后,PaddlePaddle的C-API库将被安装到`$PWD/install_android`目录,所依赖的第三方库同时也被安装到`$PWD/install_android/third_party`目录。
7076

@@ -155,7 +161,11 @@ cmake -DCMAKE_SYSTEM_NAME=Android \
155161
..
156162
```
157163

158-
用户还可根据自己的需求设置其他编译参数。比如希望最小化生成的库的大小,可以设置`CMAKE_BUILD_TYPE``MinSizeRel`;若希望最快的执行速度,则可设置`CMAKE_BUILD_TYPE``Release`。亦可以通过手动设置`CMAKE_C/CXX_FLAGS`来影响PaddlePaddle的编译过程。
164+
用户还可根据自己的需求设置其他编译参数。
165+
166+
- 设置`CMAKE_BUILD_TYPE``MinSizeRel`,最小化生成的库的大小。
167+
- 设置`CMAKE_BUILD_TYPE``Release`,获得最快的执行速度,
168+
- 用户亦可以通过手动设置`CMAKE_C/CXX_FLAGS`来影响PaddlePaddle的编译过程。
159169

160170
**性能TIPS**,为了达到最快的计算速度,在CMake参数配置上,有以下建议:
161171

doc/mobile/cross_compiling_for_android_en.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Users can directly use the published Docker image.
2525
$ docker pull paddlepaddle/paddle:latest-dev-android
2626
```
2727

28+
For users in China, we provide a faster mirror.
29+
30+
```bash
31+
$ docker pull docker.paddlepaddlehub.com/paddle:latest-dev-android
32+
```
33+
2834
### Build the Inference Library
2935

3036
We can run the Docker image we just created to build the inference library of PaddlePaddle for Android using the command below:
@@ -86,19 +92,19 @@ Android NDK includes everything we need to build the [*standalone toolchain*](ht
8692

8793
- To build the standalone toolchain for `armeabi-v7a` and Android API level 21:
8894

89-
```bash
90-
your/path/to/android-ndk-r14b-linux-x86_64/build/tools/make-standalone-toolchain.sh \
91-
--arch=arm --platform=android-21 --install-dir=your/path/to/arm_standalone_toolchain
92-
```
95+
```bash
96+
your/path/to/android-ndk-r14b-linux-x86_64/build/tools/make-standalone-toolchain.sh \
97+
--arch=arm --platform=android-21 --install-dir=your/path/to/arm_standalone_toolchain
98+
```
9399

94100
The generated standalone toolchain will be in `your/path/to/arm_standalone_toolchain`.
95101

96102
- To build the standalone toolchain for `arm64-v8a` and Android API level 21:
97103

98-
```bash
99-
your/path/to/android-ndk-r14b-linux-x86_64/build/tools/make-standalone-toolchain.sh \
100-
--arch=arm64 --platform=android-21 --install-dir=your/path/to/arm64_standalone_toolchain
101-
```
104+
```bash
105+
your/path/to/android-ndk-r14b-linux-x86_64/build/tools/make-standalone-toolchain.sh \
106+
--arch=arm64 --platform=android-21 --install-dir=your/path/to/arm64_standalone_toolchain
107+
```
102108

103109
The generated standalone toolchain will be in `your/path/to/arm64_standalone_toolchain`.
104110

paddle/scripts/docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Users can specify the following Docker build arguments with either "ON" or "OFF"
5858
| `WITH_AVX` | OFF | Set to "ON" to enable AVX support. |
5959
| `WITH_TESTING` | OFF | Build unit tests binaries. |
6060
| `WITH_MKL` | ON | Build with [Intel® MKL](https://software.intel.com/en-us/mkl) and [Intel® MKL-DNN](https://github.com/01org/mkl-dnn) support. |
61-
| `WITH_GOLANG` | ON | Build fault-tolerant parameter server written in go. |
61+
| `WITH_GOLANG` | OFF | Build fault-tolerant parameter server written in go. |
6262
| `WITH_SWIG_PY` | ON | Build with SWIG python API support. |
6363
| `WITH_C_API` | OFF | Build capi libraries for inference. |
6464
| `WITH_PYTHON` | ON | Build with python support. Turn this off if build is only for capi. |

paddle/scripts/docker/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function cmake_gen() {
4040
-DWITH_DISTRIBUTE=${WITH_DISTRIBUTE:-OFF}
4141
-DWITH_MKL=${WITH_MKL:-ON}
4242
-DWITH_AVX=${WITH_AVX:-OFF}
43-
-DWITH_GOLANG=${WITH_GOLANG:-ON}
43+
-DWITH_GOLANG=${WITH_GOLANG:-OFF}
4444
-DCUDA_ARCH_NAME=${CUDA_ARCH_NAME:-All}
4545
-DWITH_SWIG_PY=ON
4646
-DWITH_C_API=${WITH_C_API:-OFF}
@@ -65,7 +65,7 @@ EOF
6565
-DWITH_DISTRIBUTE=${WITH_DISTRIBUTE:-OFF} \
6666
-DWITH_MKL=${WITH_MKL:-ON} \
6767
-DWITH_AVX=${WITH_AVX:-OFF} \
68-
-DWITH_GOLANG=${WITH_GOLANG:-ON} \
68+
-DWITH_GOLANG=${WITH_GOLANG:-OFF} \
6969
-DCUDA_ARCH_NAME=${CUDA_ARCH_NAME:-All} \
7070
-DWITH_SWIG_PY=${WITH_SWIG_PY:-ON} \
7171
-DWITH_C_API=${WITH_C_API:-OFF} \

0 commit comments

Comments
 (0)