-
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 如何构建raspberry pi下运行的paddle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. paddle => PaddlePaddle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
这里考虑的是交叉编译方式,即在Linux-X86环境下构建raspberry pi下可运行的paddle。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. X86 => x86 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
## 下载交叉编译环境 | ||
``` | ||
git clone https://github.com/raspberrypi/tools | ||
``` | ||
如果host是x86-64环境,选用`arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64`下的作为编译工具。注意,需要系统glibc支持2.14以上。 | ||
|
||
|
||
## 编译第三方库 | ||
Paddle在cmake会在编译paddle的时候自动编译依赖的第三方库,不过openblas和protobuf最好还是在编译paddle之前先编译好,这样可以保证编译paddle的时候更加顺畅。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
==>
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
为什么最好?和依赖cmake去下载和编译OpenBLAS和protobuf有什么区别?我理解这个工作应该是让在Raspberry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在交叉编译方式下,直接依赖cmake去下载和编译中间会断掉,不能一次cmake & make成功。比如,编译protobuf时编译出来的 |
||
|
||
### 编译openblas | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. openblas => OpenBLAS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
``` | ||
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`。 | ||
|
||
|
||
## 编译Paddle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paddle ==> PaddlePaddle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
``` | ||
cmake .. -DWITH_GPU=OFF -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 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ FILE(GLOB PY_PADDLE_PYTHON_FILES ${PROJ_ROOT}/paddle/py_paddle/*.py) | |
SET_SOURCE_FILES_PROPERTIES(Paddle.i PROPERTIES CPLUSPLUS ON) | ||
|
||
SET(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
SET(CMAKE_CXX_FLAGS "-std=c++11 -fPIC -Wall") | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
IF(WITH_COVERAGE) | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") | ||
ENDIF(WITH_COVERAGE) | ||
|
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.
raspberry pi => Raspberry Pi
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.
Done