在rk3399(rockpi 4b)上部署Tengine AI框架(GPU)测试(linux-4.4)

  • 构建可用的环境
    由于瑞芯微提供的bsp中的内核版本为4.4,所以各个开发板的厂家提供的长期维护的内核版本也是4.4,

在5.3.x的环境下只是跑起来了opengl 但是opencl始终无法运行起来,

因为手里面只有rockpi4b的板子,rockpi目前没有找到支持opencl的系统,我在网上找到了firefly的ubuntu18.04的系统,这个系统已经移植好了opencl1.2,可以直接使用,

只是后面想进行一些个性化的更改可能会受限,不过目前可以用于进行一些测试

如下在上面进行了glmark2的测试,

opencl1.2也显示是可用的


  • 部署 Tengine AI 框架(GPU)

Tengine的编译看
这里

编译Tengine with ACL

Tengine是通过调用Arm Compute Library(ACL)进行GPU加速。

首先编译ACL
#编译ACL
root@firefly:/home/gpu# git clone https://github.com/ARM-software/ComputeLibrary.git
#切换19.02分支
root@firefly:/home/gpu/ComputeLibrary# git checkout -b v19.02 v19.02
#编译
scons Werror=1 -j4 debug=0 asserts=0 neon=0 opencl=1 embed_kernels=1 os=linux arch=arm64-v8a

然后在Tengine中使能ACL
#修改default/arm64_linux_native.config文件
root@firefly:/home/gpu/tengine# vi default_config/arm64_linux_native.config
 
#The following option is used for building acl or not. [y/n]
#option value [y/n]
BUILD_ACL=y
 
#The following option are used for setting acl only if turning on the BUILD_ACL option
ACL_ROOT=/home/gpu/ComputeLibrary
#注意ACL的路径
 
#执行编译
root@firefly:/home/gpu/tengine# ./linux_build.sh default_config/arm64_linux_native.config

测试!

首先来看一下没有GPU的情况下,tengine默认使用的是2*A72的大核进行测试的,以mobilenet_ssd的模型进行测试

可以看到CPU的占用情况,以及执行50次的平均耗时为170.881ms

然后以GPU+1*A53的情况下进行测试

#设置gpu的频率未固定的最大值
root@firefly:/home/gpu/tengine/examples/build# echo "performance" > /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/governor
#查看一下
root@firefly:/home/gpu/tengine/examples/build# cat /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/cur_freq
800000000
root@firefly:/home/gpu/tengine/examples/build#
 
# disable gpu run concat,     avoid frequent data transfer between cpu and gpu
root@firefly:/home/gpu/tengine/examples/build# export GPU_CONCAT=0
 
# enable gpu fp16
root@firefly:/home/gpu/tengine/examples/build# export ACL_FP16=1
 
# repeat count to run mssd,     get avg time
root@firefly:/home/gpu/tengine/examples/build# export REPEAT_COUNT=50
 
# run acl graph on NHWC layout
root@firefly:/home/gpu/tengine/examples/build# export ACL_NHWC=1
 
#把opencl的系统库添加到系统环境中
root@firefly:/home/gpu/tengine/install/lib# export LD_LIBRARY_PATH=/home/gpu/tengine/install/lib/
 
#执行 -d acl_opencl to use gpu, taskset 0x1 to bind CPU0(A53)
root@firefly:/home/gpu/tengine/examples/build# taskset 0x1 ./mobilenet_ssd/MSSD -d acl_opencl

posted @ 2020-07-28 09:15  tccxy  阅读(1275)  评论(1编辑  收藏  举报