Skip to content
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

take rk3399 as an android device #139

Open
Ziv-Huang opened this issue Jun 1, 2018 · 16 comments
Open

take rk3399 as an android device #139

Ziv-Huang opened this issue Jun 1, 2018 · 16 comments
Assignees

Comments

@Ziv-Huang
Copy link

Hi all,

I want to run the caffe-classification in firefly rk3399, so i take it as an android device
and connect to a host machine via ADB. It can work on cpu mode, but i have no idea about how to work on gpu.

have any suggestion ?
thanks.

@Chunosov
Copy link
Contributor

Chunosov commented Jun 1, 2018

You have to install one gpu-aware packages using android target flag, e.g.:

ck install package:lib-caffe-bvlc-opencl-clblast-universal --target_os=android23-arm-v7a

Then rebuild classification program against this package and using the same target flag, and then run it with the same flag.

Honestly I'm not pretty sure which flag should be used for firefly. You can list all available android targets via command

ck ls os:android*

@Ziv-Huang
Copy link
Author

@Chunosov thanks for your reply !!

when i try to this command :
"ck install package:lib-caffe-bvlc-opencl-clblast-universal --target_os=android23-arm-v7a"

it can't find file to patch:
Patching source directory ...
/home/alvin/CK/ck-env/package/lib-protobuf-3.2.0-android/patch.android/patch
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:

|diff -ruN protobuf-3.2.0\cmake\install.cmake protobuf-3.2.0-new\cmake\install.cmake
|--- protobuf-3.2.0\cmake\install.cmake Fri Jan 27 23:03:40 2017
|+++ protobuf-3.2.0-new\cmake\install.cmake Wed May 10 10:07:15 2017

However, i find the patch exists in the path.
why ????

@gfursin
Copy link
Contributor

gfursin commented Jun 1, 2018

Ups, that's my fault, @Ziv-Huang . I added ProtoBuf 3.2.0+ packages for Android recently and tested them on Windows (cross-compiling for Android). Unfortunately, patches prepared on Windows are incompatible with Linux (opposite is ok), so I updated them right now and committed. You should now be able to build them. Can you please do the following:

$ ck pull all
$ ck install package:lib-protobuf-3.2.0-android --target_os=android23-arm-v7a

and then restart Caffe build, please?
Thanks!

@gfursin
Copy link
Contributor

gfursin commented Jun 1, 2018

The idea behind CK is to let the community use shared workflows and collaboratively fix encountered portability issues in shared packages across different platforms (like in your case), so thanks for your feedback!

@Ziv-Huang
Copy link
Author

@gfursin thanks,

it also can't find file to patch

$ ck install package:lib-protobuf-3.2.0-android --target_os=android23-arm-v7a

Patching source directory ...
/home/alvin/CK/ck-env/package/lib-protobuf-3.2.0-android/patch.android/patch
patching file cmake/install.cmake
patching file cmake/libprotoc.cmake
patching file cmake/protoc.cmake
/home/alvin/CK/ck-env/package/lib-protobuf-3.2.0-android/patch.android/patch.orig
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:

|diff -ruN protobuf-3.2.0\cmake\install.cmake protobuf-3.2.0-new\cmake\install.cmake
|--- protobuf-3.2.0\cmake\install.cmake Fri Jan 27 23:03:40 2017
|+++ protobuf-3.2.0-new\cmake\install.cmake Wed May 10 10:07:15 2017

File to patch:

@gfursin
Copy link
Contributor

gfursin commented Jun 1, 2018

I think you have an old or polluted repository. I don't see patch.orig in the master GitHub branch:

$ ck renew repo:ck-env

It will remove your current ck-env repo and will install a clean one - this should fix your problem ...

@Ziv-Huang
Copy link
Author

Ziv-Huang commented Jun 4, 2018

@Chunosov @gfursin it works, thanks.

I have a question about caffe-classification and caffe-classification-opencl,

when i use caffe-classification-opencl, it shows the mode is gpu,
so the caffe-classification is only cpu mode?

therefore, i try this
"$ ck compile program:caffe-classification-opencl --speed --target_os=android21-arm"
"$ ck run program:caffe-classification-opencl --target_os=android21-arm"

because i want to run the classification on the gpu of rk3399,
but it shows that

executing code ...
WARNING: linker: Warning: unable to normalize ""
CANNOT LINK EXECUTABLE "./classification": library "libOpenCL.so" not found
Aborted

but i find the libOpenCL.so in the env/xxxxxxxxxxxxxx, how can i do to link it?

@gfursin
Copy link
Contributor

gfursin commented Jun 4, 2018

Yes, that's right. caffe-classification is only for CPU mode ...

As for libOpenCL.so not found, note that libOpenCL.so on your host is a stub, i.e. it is used just to link an interface to the caffe-classification client, while the library itself is provided by a vendor and will be linked dynamically from your RK3399. This error means that libOpenCL.so is not in a standard path on your RK3399 - you need to find where it is on your device and provide us a path - if it's indeed non standard - we can add a support for it in the CK ...

You can also test the following command:

$ ck detect platform.gpgpu --opencl --target_os=android21-arm

@Chunosov, @psyhtest - can you please tell us where is libOpenCL.so on our RK3399? Thanks!

@Chunosov
Copy link
Contributor

Chunosov commented Jun 4, 2018

I can only find it in various opencl-1.2-stubs directories inside of CK-TOOLS...

@gfursin
Copy link
Contributor

gfursin commented Jun 4, 2018

@Chunosov - I speak about remove device (accessed via adb), not the host! You will not find vendor OpenCL libraries for Android on the host machine ...

@gfursin
Copy link
Contributor

gfursin commented Jun 4, 2018

Someone suggested to find it as follows:

adb shell 'find / -name libOpenCL.so 2>/dev/null

I didn't test it though ...

@gfursin
Copy link
Contributor

gfursin commented Jun 4, 2018

Another possible issue is that it's not called libOpenCL.so but something else. In such case you may need to make a soft link to libOpenCL.so . I think we need to wait for an advice from @psyhtest !

@Chunosov
Copy link
Contributor

Chunosov commented Jun 4, 2018

Actually I didn't search it on my host. I've logged onto firefly and searched there with

cd /
find . -type f -name libOpenCL.so

@psyhtest
Copy link
Member

psyhtest commented Jun 4, 2018

@gfursin No idea :). @Ziv-Huang's RK3399 is running under Android, while ours is running under Linux. FWIW, the library may be called libmali.so.

@Chunosov It's weird you could find it.

@Ziv-Huang
Copy link
Author

I test the command "$ ck detect platform.gpgpu --opencl --target_os=android21-arm", and it shows that:


Resolving software dependencies ...

*** Dependency 1 = adb (adb tool):

Resolved. CK environment UID = f7ee4c6cbbcab317 (detected version 1.0.32)
Available remote devices:
FFHYHTC001813000524VP1

Initializing device ...

OS CK UOA: android21-arm (4d0f80a65f56a174)

OS name: Android 7.1.2
Short OS name: Linux version 4.4.83
Long OS name: Linux version 4.4.83 (build@build-desktop) (gcc version 4.9 20150123 (prerelease) (GCC) ) #1 SMP PREEMPT Mon May 7 17:19:01 CST 2018
OS bits: 32

Device serial number: FFHYHTC001813000524VP1

Platform init UOA: cd0fdb5de4e07ad7

Number of logical processors: 6
Number of unique processors: 2

Unique processor: 0
CPU name: 0x41-8-0x0-0xd03-4
CPU ABI: arm64-v8a
CPU features: fp asimd evtstrm aes pmull sha1 sha2 crc32

Unique processor: 1
CPU name: 0x41-8-0x0-0xd08-2
CPU ABI: arm64-v8a
CPU features: fp asimd evtstrm aes pmull sha1 sha2 crc32

CPU frequency:
CPU0 = 408.0 MHz
CPU1 = 408.0 MHz
CPU2 = 408.0 MHz
CPU3 = 408.0 MHz
CPU4 = 816.0 MHz
CPU5 = 408.0 MHz
CPU max frequency:
CPU0 = 1416.0 MHz
CPU1 = 1416.0 MHz
CPU2 = 1416.0 MHz
CPU3 = 1416.0 MHz
CPU4 = 1800.0 MHz
CPU5 = 1800.0 MHz
CPU all frequencies (Hz):
CPU0 = [408000, 600000, 816000, 1008000, 1200000, 1416000]
CPU1 = [408000, 600000, 816000, 1008000, 1200000, 1416000]
CPU2 = [408000, 600000, 816000, 1008000, 1200000, 1416000]
CPU3 = [408000, 600000, 816000, 1008000, 1200000, 1416000]
CPU4 = [408000, 600000, 816000, 1008000, 1200000, 1416000, 1608000, 1800000]
CPU5 = [408000, 600000, 816000, 1008000, 1200000, 1416000, 1608000, 1800000]

Detecting GPGPU type: opencl

Initializing device ...
244 KB/s (10768 bytes in 0.043s)

WARNING: no CK-enabled GPGPU devices found ...


does it mean that no opencl exists in rk3399?
so i can't test it's gpu by this method?
or have other methods to test it's gpu on android?

thanks !!!

@gfursin
Copy link
Contributor

gfursin commented Jun 7, 2018

@Ziv-Huang . If a vendor didn't provide OpenCL library to your platform, then OpenCL-version of Caffe will not work. There are two possible solutions:

  1. It may still be a non-standard library name for OpenCL library on your platform. Can you please provide an output of the following commands:
$ adb shell ls /system/vendor
$ adb shell ls /system/vendor/lib
$ adb shell ls /system/vendor/lib64

For example, on my Samsung Galaxy S7 you can see the following:

egl
hw
libOpenCL.so
libOpenCL.so.1
libOpenCL.so.1.1
libRSDriverArm.so
libbccArm.so
libmalicore.bc
libskia_opt.so
mediadrm
  1. If there is still no OpenCL lib, you may try to find a BSP (Android image) for your board which will support OpenCL - you need to check with your board provider ...

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

No branches or pull requests

5 participants