-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compile on raspberry pi #1835
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e128861
Fix compile on raspberry pi
hedaoyuan 5ba7f61
follow comment
hedaoyuan fe7825b
follow comments
hedaoyuan 98e1033
Merge branch 'develop' of https://github.com/baidu/Paddle into raspbe…
hedaoyuan 5cdc495
Fix some bug
hedaoyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 如何构建Raspberry pi下运行的PaddlePaddle | ||
|
||
这里考虑的是交叉编译方式,即在Linux-x86环境下构建Raspberry pi下可运行的PaddlePaddle。 | ||
|
||
## 下载交叉编译环境 | ||
``` | ||
git clone https://github.com/raspberrypi/tools | ||
``` | ||
如果host是x86-64环境,选用`arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64`下的作为编译工具。注意,需要系统glibc支持2.14以上。 | ||
|
||
|
||
## 编译第三方库 | ||
cmake编译PaddlePaddle时候会自动下载编译依赖的第三方库,不过openblas和protobuf最好还是在编译PaddlePaddle之前先编译好,这样可以保证编译PaddlePaddle的时候更加顺畅。 | ||
|
||
### 编译OpenBLAS | ||
``` | ||
git clone https://github.com/xianyi/OpenBLAS.git | ||
make TARGET=ARMV7 HOSTCC=gcc CC=arm-linux-gnueabihf-gcc NOFORTRAN=1 USE_THREAD=0 | ||
``` | ||
|
||
### 编译protobuf | ||
``` | ||
git clone https://github.com/google/protobuf.git | ||
git checkout 9f75c5aa851cd877fb0d93ccc31b8567a6706546 | ||
cmake ../protobuf/cmake \ | ||
-Dprotobuf_BUILD_TESTS=OFF \ | ||
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \ | ||
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \ | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_INSTALL_LIBDIR=lib | ||
``` | ||
注意:这样编译出来的`libprotobuf.a`和`protoc`都是ARM版本的,而我们需要的是一个x86-64版本的`protoc`,所以需要用host gcc再编译一遍protobuf然后使用其中的`protoc`。 | ||
|
||
|
||
## 编译PaddlePaddle | ||
cmake参数如下;其中`WITH_C_API`设置为ON,编译输出的output目录会中包含`include`和`lib`目录,其中`include`中包含CAPI的头文件,`lib`中包含一个ARM版本的库。另外,`CMAKE_BUILD_TYPE`设置为`MinSizeRel`可以减小编译的库的大小。 | ||
``` | ||
cmake .. -DWITH_GPU=OFF -DWITH_C_API=ON -DWITH_PYTHON=OFF -DWITH_SWIG_PY=OFF \ | ||
-DCMAKE_CXX_COMPILER:FILEPATH=arm-linux-gnueabihf-g++ \ | ||
-DCMAKE_C_COMPILER:FILEPATH=arm-linux-gnueabihf-gcc \ | ||
-DCMAKE_C_FLAGS="-mfpu=neon" \ | ||
-DCMAKE_CXX_FLAGS="-mfpu=neon" \ | ||
-DOPENBLAS_ROOT=openblas \ | ||
-DCMAKE_PREFIX_PATH=protobuf \ | ||
-DCMAKE_BUILD_TYPE=MinSizeRel | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍