ORNEW

MacでTensorflowのAndroidデモをビルドしたメモ

Share on Facebook
Pocket

on Mac

前略。TensorFlow r0.9

・NDKにRELEASE.TXTがねーよ!と怒られる件
適当に作ったら通った(謎)

・Android用のgccがねーよって怒られる件
↓エラー内容

ERROR: /private/var/tmp/_bazel_NNM/53ee56ff2dcdc5430a62549fd9c76927/external/protobuf/BUILD:111:1: C++ compilation of rule '@protobuf//:protobuf' failed: arm-linux-androideabi-gcc failed: error executing command external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc -fstack-protector-strong -fpic -ffunction-sections -funwind-tables -no-canonical-prefixes ... (remaining 51 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
process-wrapper: execvp("external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc", ...): No such file or directory

かなり悩んだけど、darwin-x86_x64ならあるのでそれで検索したらリポジトリのIssue(https://github.com/tensorflow/tensorflow/issues/1593)で「x86_x64をx86に変えたら動くよ」っていう力技で解決されてて困惑したもののやってみたら通った(本当にこれでいいのか…??????????)

Target //tensorflow/examples/android:tensorflow_demo up-to-date:
bazel-bin/tensorflow/examples/android/tensorflow_demo_deploy.jar
bazel-bin/tensorflow/examples/android/tensorflow_demo_unsigned.apk
bazel-bin/tensorflow/examples/android/tensorflow_demo.apk
INFO: Elapsed time: 318.310s, Critical Path: 315.84s

5分くらい

Genymotionで動かそうとしたけどABIが違うって怒られた

$ adb install -r -g bazel-bin/tensorflow/examples/android/tensorflow_demo.apk
48770 KB/s (2842861 bytes in 0.056s)
pkg: /data/local/tmp/tensorflow_demo.apk
Failure [INSTALL_FAILED_NO_MATCHING_ABIS]

x86とx86_64も入れる。

$ bazel build --fat_apk_cpu=x86,x86_64 //tensorflow/examples/android:tensorflow_demo

Genymotionでは正常に動かなかった…。
Camera2がサポート外環境として落ちてます。

07-05 02:37:24.731 1061-1173/com.android.launcher3 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xe8a214a0
07-05 02:37:25.044 679-682/? E/gralloc_vbox86: gralloc_alloc: Requested YCbCr_420_888, but no known specific format for this usage: 640 x 480, usage 3
07-05 02:37:25.044 679-682/? E/gralloc_vbox86: gralloc_alloc: Unknown format 35
07-05 02:37:25.049 1645-1733/org.tensorflow.demo E/BufferQueueProducer: [ImageReader-640x480f23m2-1645-1] dequeueBuffer: createGraphicBuffer failed
07-05 02:37:25.049 1645-1733/org.tensorflow.demo E/Legacy-CameraDevice-JNI: LegacyCameraDevice_nativeProduceFrame: Error while producing frame Invalid argument (-22).
07-05 02:37:25.188 1645-1733/org.tensorflow.demo E/BufferQueueProducer: [ImageReader-640x480f23m2-1645-1] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count
07-05 02:37:25.188 1645-1733/org.tensorflow.demo E/Legacy-CameraDevice-JNI: LegacyCameraDevice_nativeProduceFrame: Error while producing frame Function not implemented (-38).
07-05 02:37:25.188 1645-1733/org.tensorflow.demo E/CameraDeviceGLThread-0: Received exception on GL render thread: 
                                                                           java.lang.UnsupportedOperationException: Unknown error -38
                                                                               at android.hardware.camera2.legacy.LegacyExceptionUtils.throwOnError(LegacyExceptionUtils.java:69)
                                                                               at android.hardware.camera2.legacy.LegacyCameraDevice.produceFrame(LegacyCameraDevice.java:636)
                                                                               at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:750)
                                                                               at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                               at android.os.Looper.loop(Looper.java:148)
                                                                               at android.os.HandlerThread.run(HandlerThread.java:61)
07-05 02:37:29.089 1645-1732/org.tensorflow.demo E/RequestThread-0: Timed out while waiting for request to complete.
07-05 02:37:29.089 1645-1732/org.tensorflow.demo E/CameraDeviceState: Cannot receive result while in state: 0
07-05 02:37:29.089 1645-1732/org.tensorflow.demo E/CameraDeviceState: Cannot receive result while in state: 0
07-05 02:37:29.089 1645-1732/org.tensorflow.demo E/CameraDeviceState: Cannot receive result while in state: 0
07-05 02:37:29.094 1645-1733/org.tensorflow.demo E/Surface: getSlotFromBufferLocked: unknown buffer: 0xeb0b9620
07-05 02:37:29.095 1645-1656/org.tensorflow.demo E/BufferQueueProducer: [SurfaceTexture-1-1645-3] dequeueBuffer: BufferQueue has been abandoned
07-05 02:37:29.095 373-1735/? E/EmulatedCamera_Preview: onNextFrameAvailable: Unable to dequeue preview window buffer: 19 -> No such device
07-05 02:37:29.107 373-373/? E/CameraService: disconnect: Disconnect called on already disconnected client for device 0

                                              [ 07-05 02:37:29.115   685:  811 D/         ]
                                              HostConnection::get() New Host Connection established 0xda1b0be0, tid 811
07-05 02:37:29.142 679-679/? E/EGL_emulation: tid 679: eglCreateSyncKHR(1215): error 0x3004 (EGL_BAD_ATTRIBUTE)
07-05 02:37:29.338 1645-1660/org.tensorflow.demo E/Surface: getSlotFromBufferLocked: unknown buffer: 0xeb0c2310