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

ndk从17升级到21后,推论报错 “library "libomp.so" not found” #1157

Closed
zhuoran-guo opened this issue Jul 16, 2021 · 8 comments
Closed
Assignees

Comments

@zhuoran-guo
Copy link

ndk17的时候没有问题,到ndk21的时候报错,
adb -H "host.docker.internal" -s 717cc280 shell "export LD_LIBRARY_PATH=/data/local/tmp/ai-performance/tnn/android-armv8; /data/local/tmp/ai-performance/tnn/android-armv8/TNNTest -mt tnn -mp /data/local/tmp/ai-performance/tnn/incam-face-c-7.0-2.0.tnnproto -dt ARM -ic 100 -wc 20 -th 1 -dl 0,1"
CANNOT LINK EXECUTABLE "/data/local/tmp/ai-performance/tnn/android-armv8/TNNTest": library "libomp.so" not found
Aborted
�cmakelist.txt里面,TNN_OPENMP_ENABLE=OFF了,为啥还报错找不到libomp.so的库?
而且TNN_OPENMP_ENABLE=ON之后也一样报错

@powerpwang
Copy link
Collaborator

可直接从ndk r21中拷贝一份libomp.so到手机目录上
libomp.so可以在ndk里面找一下,所在目录大概是android-ndk-r21d/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/9.0.8/lib/linux/aarch64/libomp.so
你可以使用adb push手动将libomp.so传到手机上
adb push libomp.so /data/local/tmp/ai-performance/tnn/android-armv8

@zhuoran-guo
Copy link
Author

@powerpwang
好的谢谢,搞定了,
用了arm82后cpu的速度提高了不少,但是opencl GPU几乎没有变化
TNN有啥优化方法可以提高设备GPU端的速度吗?

@powerpwang
Copy link
Collaborator

设备GPU端的速度不受ARM82影响,升级ARM82后opencl GPU速度没有提升是正常的。
设备GPU端看下目前是否有开启tune,如果没开的话,打开tune去测试下 (./TNNTest -et)

@quinnrong94
Copy link
Collaborator

高版本ndk使用静态openmp库可避免这个问题:android/ndk#1028
已修改TNN编译选项:#1161

@zhuoran-guo
Copy link
Author

@powerpwang
你好,请问tune是怎么打开呢?
有没有教程

@lnmdlong
Copy link
Collaborator

@zhuoran-guo 参考 https://github.com/Tencent/TNN/blob/master/doc/en/user/api_en.md 这个文档,TNN NetworkConfig里面设置enable_tune_kernel为true

@zhuoran-guo
Copy link
Author

@lnmdlong
好的谢谢,tune设置为true之后,一张图片的推论时间从15.768ms → 14.529ms,速度大概提高了8.5%
图片的尺寸是{1, 3, 320, 416},使用的模型是mobilenetv2, 设备是qcs605
请问还有什么办法能增加TNN在GPU上的推论速度吗?
这个速度属于TNN能力的正常范围吗?
谢谢

@SanjunLiu
Copy link

可以试一下,改成静态的形式
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
if (DEFINED ANDROID_NDK_MAJOR AND ${ANDROID_NDK_MAJOR} GREATER 20)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-openmp")
endif ()

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

No branches or pull requests

5 participants