Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

请问有paddlepaddle应用到Android的Demo吗 #43

Closed
yeyupiaoling opened this issue Dec 3, 2017 · 13 comments · Fixed by #47
Closed

请问有paddlepaddle应用到Android的Demo吗 #43

yeyupiaoling opened this issue Dec 3, 2017 · 13 comments · Fixed by #47

Comments

@yeyupiaoling
Copy link
Contributor

我看了那么久的文档,都不知道怎么使用,比如在手机上识别手写数字

@Xreki
Copy link
Collaborator

Xreki commented Dec 6, 2017

@yeyupiaoling
Copy link
Contributor Author

@Xreki 那命令之前看过,最后的那部分不知道怎么做,你们努力,我为你们打call,我也要好好学习,看能不能为paddlepaddle贡献点什么。

@yeyupiaoling
Copy link
Contributor Author

yeyupiaoling commented Dec 6, 2017

@Xreki 我安装你给的这个教程在第二步的make时报错
[ 17%] Linking CXX static library libpaddle_cuda.a
cpplint: Checking source code style
Traceback (most recent call last):
paddle/cuda/CMakeFiles/paddle_cuda.dir/build.make:146: recipe for target 'paddle/cuda/libpaddle_cuda.a' failed
make[2]: *** [paddle/cuda/libpaddle_cuda.a] Error 1
make[2]: *** Deleting file 'paddle/cuda/libpaddle_cuda.a'
CMakeFiles/Makefile2:894: recipe for target 'paddle/cuda/CMakeFiles/paddle_cuda.dir/all' failed
make[1]: *** [paddle/cuda/CMakeFiles/paddle_cuda.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
不知道是不是我的go的版本问题,我的版本是go version go1.6.2 linux/amd64

@Xreki
Copy link
Collaborator

Xreki commented Dec 7, 2017

最后的那部分不知道怎么做

是说Run the demo program by logging into the Android environment via adb and specifying the PaddlePaddle model from the command line as follows这部分吗?这部分是通过Android的adb工具,将生成的二进制文件传输到Android手机上,然后adb shell登陆到Android手机上,以命令行的方式执行可执行程序,遇到什么问题可以详细地在这里列出来。另外,我们的文档也有不完善之处,欢迎多多提建议。

你们努力,我为你们打call,我也要好好学习,看能不能为paddlepaddle贡献点什么。

多谢你的支持,非常欢迎你的贡献。

我安装你给的这个教程在第二步的make时报错

你是自己搭建交叉编译环境来编译Android版本吧。这个错误跟go的版本没关系。具体贴一下你的cmake命令和cmake输出吧。

@yeyupiaoling
Copy link
Contributor Author

@Xreki 我执行的cmake是:
cmake .. \ -DANDROID_ABI=armeabi-v7a \ -DANDROID_STANDALONE_TOOLCHAIN=/home/wang/ubuntu/paddlepaddle/android/arm_standalone_toolchain \ -DPADDLE_ROOT=/home/wang/ubuntu/paddlepaddle/android/install \ -DCMAKE_BUILD_TYPE=MinSizeRel

他输出的日志是:

-- Found Paddle host system: ubuntu, version: 16.04.3
-- Found Paddle host system's CPU: 2 cores
-- The CXX compiler identification is GNU 5.4.0
-- The C compiler identification is GNU 5.4.0
-- The Golang compiler identification is go1.6.2 linux/amd64
-- Check for working Golang compiler: /usr/bin/go
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Could NOT find Sphinx (missing:  SPHINX_EXECUTABLE) 
-- Found Git: /usr/bin/git (found version "2.7.4") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Performing Test MMX_FOUND
-- Performing Test MMX_FOUND - Success
-- Performing Test SSE2_FOUND
-- Performing Test SSE2_FOUND - Success
-- Performing Test SSE3_FOUND
-- Performing Test SSE3_FOUND - Success
-- Performing Test AVX_FOUND
-- Performing Test AVX_FOUND - Failed
-- Performing Test AVX2_FOUND
-- Performing Test AVX2_FOUND - Failed
-- Protobuf protoc executable: /media/wang/软件/ubuntu/paddlepaddle/paddle-src/paddle3/build/third_party/install/protobuf/bin/protoc
-- Protobuf library: /media/wang/软件/ubuntu/paddlepaddle/paddle-src/paddle3/build/third_party/install/protobuf/lib/libprotobuf.a
-- Protobuf version: 3.1
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.7") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.12", minimum required is "2.7") 
-- Found PY_pip: /usr/local/lib/python2.7/dist-packages/pip  
-- Found PY_numpy: /usr/local/lib/python2.7/dist-packages/numpy  
-- Found PY_wheel: /usr/lib/python2.7/dist-packages/wheel  
-- Found PY_google.protobuf: /usr/local/lib/python2.7/dist-packages/google/protobuf  
-- Found NumPy: /usr/local/lib/python2.7/dist-packages/numpy/core/include  
-- BLAS library: /media/wang/软件/ubuntu/paddlepaddle/paddle-src/paddle3/build/third_party/install/openblas/lib/libopenblas.a
-- Found SWIG: /usr/bin/swig3.0 (found version "3.0.8") 
-- warp-ctc library: /media/wang/软件/ubuntu/paddlepaddle/paddle-src/paddle3/build/third_party/install/warpctc/lib/libwarpctc.so
-- Looking for UINT64_MAX
-- Looking for UINT64_MAX - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of pthread_spinlock_t
-- Check size of pthread_spinlock_t - done
-- Check size of pthread_barrier_t
-- Check size of pthread_barrier_t - done
-- Performing Test C_COMPILER_SUPPORT_FLAG__fPIC
-- Performing Test C_COMPILER_SUPPORT_FLAG__fPIC - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__fPIC
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__fPIC - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__fno_omit_frame_pointer
-- Performing Test C_COMPILER_SUPPORT_FLAG__fno_omit_frame_pointer - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__fno_omit_frame_pointer
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__fno_omit_frame_pointer - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wall
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wall - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wall
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wall - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wextra
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wextra - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wextra
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wextra - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Werror
-- Performing Test C_COMPILER_SUPPORT_FLAG__Werror - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Werror
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Werror - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wnon_virtual_dtor
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wnon_virtual_dtor - Failed
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wnon_virtual_dtor
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wnon_virtual_dtor - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wdelete_non_virtual_dtor
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wdelete_non_virtual_dtor - Failed
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wdelete_non_virtual_dtor
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wdelete_non_virtual_dtor - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_unused_parameter
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_unused_parameter - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_unused_parameter
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_unused_parameter - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_unused_function
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_unused_function - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_unused_function
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_unused_function - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_literal_suffix
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_literal_suffix - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_literal_suffix
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_literal_suffix - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_sign_compare
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_sign_compare - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_sign_compare
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_sign_compare - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_unused_local_typedefs
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_unused_local_typedefs - Success
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_unused_local_typedefs
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_unused_local_typedefs - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_parentheses_equality
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_parentheses_equality - Failed
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_parentheses_equality
-- Performing Test CXX_COMPILER_SUPPORT_FLAG__Wno_error_parentheses_equality - Failed
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_unused_function
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_unused_function - Success
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_array_bounds
-- Performing Test C_COMPILER_SUPPORT_FLAG__Wno_error_array_bounds - Success
CMake Warning at cmake/version.cmake:20 (message):
  Cannot add paddle version from git tag
Call Stack (most recent call first):
  CMakeLists.txt:141 (include)


-- Paddle version is 0.0.0
-- Skip compiling with MKLDNNMatrix
-- Skip compiling with MKLDNNLayers and MKLDNNActivations
CMake Deprecation Warning at /usr/local/share/cmake-3.8/Modules/UseSWIG.cmake:226 (message):
  SWIG_ADD_MODULE is deprecated.  Use SWIG_ADD_LIBRARY instead.
Call Stack (most recent call first):
  paddle/api/CMakeLists.txt:56 (SWIG_ADD_MODULE)


-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    ANDROID_ABI
    ANDROID_STANDALONE_TOOLCHAIN
    PADDLE_ROOT


-- Build files have been written to: /media/wang/软件/ubuntu/paddlepaddle/paddle-src/paddle3/build

@Xreki
Copy link
Collaborator

Xreki commented Dec 7, 2017

你这是在编译Android版Paddle吧,可能我们的文档让你误解了。

编译Android版Paddle(http://www.paddlepaddle.org/docs/develop/documentation/zh/mobile/cross_compiling_for_android_cn.html#linux ),按照这个步骤来:

  • 下载NDK,生成自己的独立工具链
  • 配置cmake:
mkdir build
cmake -DCMAKE_SYSTEM_NAME=Android \
      -DANDROID_STANDALONE_TOOLCHAIN=/home/wang/ubuntu/paddlepaddle/android/arm_standalone_toolchain \
      -DANDROID_ABI=armeabi-v7a \
      -DANDROID_ARM_NEON=ON \
      -DANDROID_ARM_MODE=ON \
      -DUSE_EIGEN_FOR_BLAS=ON \
      -DCMAKE_INSTALL_PREFIX=/home/wang/ubuntu/paddlepaddle/android/install \
      -DWITH_C_API=ON \
      -DWITH_SWIG_PY=OFF \
      ..
make
make install

以上是https://github.com/PaddlePaddle/Mobile/blob/develop/benchmark/tool/C/README.md 里面的第1步。然后再依次按文档执行第2,3,4步。

@Xreki Xreki changed the title 请问有paddlepaddle应用到Android的Dome吗 请问有paddlepaddle应用到Android的Domo吗 Dec 7, 2017
@yeyupiaoling
Copy link
Contributor Author

是的,我是安装步骤一步步来的,我出错的是第2步的,下面的命令

cmake .. \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_STANDALONE_TOOLCHAIN=/home/wang/ubuntu/paddlepaddle/android/arm_standalone_toolchain \
-DPADDLE_ROOT=/home/wang/ubuntu/paddlepaddle/android/install \
-DCMAKE_BUILD_TYPE=MinSizeRel

@yeyupiaoling
Copy link
Contributor Author

你们的文档写的很详细,我是按照教程来的,我觉得是我的环境问题

@yeyupiaoling
Copy link
Contributor Author

Compile inference.cc to an executable program for the Android environment as follows:
这句话不是很了解,我是要编译inference.cc,还是只执行下面的那些命令?

@Xreki
Copy link
Collaborator

Xreki commented Dec 7, 2017

是的,我是安装步骤一步步来的,我出错的是第2步的,下面的命令

确认一下,第一步,你已经成功编译了PaddlePaddle库了吗?
#43 (comment) 的cmake的输出来看,这是在配置Paddle,而不是inference这个demo啊。

Compile inference.cc to an executable program for the Android environment as follows:

这句话,是教你配置和编译inference.cc,你需要进入到Mobile/benchmark/tool/C这个目录,然后执行下面的命令配置和编译。make完了之后,你会在build目录下看到inference这样一个可执行文件。

@Xreki
Copy link
Collaborator

Xreki commented Dec 7, 2017

第2步cmake的输出应该是类似这样的(arm64-v8a版本):

-- The CXX compiler identification is GNU 4.9.0
-- The C compiler identification is GNU 4.9.0
-- Check for working CXX compiler: /home/work/liuyiqun/install/android/toolchains/arm64-android-21/bin/aarch64-linux-android-g++
-- Check for working CXX compiler: /home/work/liuyiqun/install/android/toolchains/arm64-android-21/bin/aarch64-linux-android-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /home/work/liuyiqun/install/android/toolchains/arm64-android-21/bin/aarch64-linux-android-gcc
-- Check for working C compiler: /home/work/liuyiqun/install/android/toolchains/arm64-android-21/bin/aarch64-linux-android-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PaddlePaddle (include: /home/work/liuyiqun/PaddlePaddle/Paddle/build_paddle/dist_android/include/paddle; library: /home/work/liuyiqun/PaddlePaddle/Paddle/build_paddle/dist_android/lib/arm64-v8a/libpaddle_capi_shared.so)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/work/liuyiqun/PaddlePaddle/Mobile/benchmark/tool/C/build

@Xreki Xreki changed the title 请问有paddlepaddle应用到Android的Domo吗 请问有paddlepaddle应用到Android的Demo吗 Dec 7, 2017
@yeyupiaoling
Copy link
Contributor Author

我明白了,因为在第一步的时候,我是在paddle的根目录下执行cmake的,所以我在第二步时,也就习惯在paddle根目录下执行那些命令了,所以才会出现这些问题。谢谢你了!

@Xreki
Copy link
Collaborator

Xreki commented Dec 7, 2017

不客气。这个repo下的文档可能描述的不够清楚,我们也会尽快完善,:smile:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants