Vulkan NDK编译问题 及 Linux 端,Vulkan/OpenCL 推理出错
平台(如果交叉编译请再附上交叉编译目标平台):
Platform(Include target platform as well if cross-compiling):
Ubuntu 18.04 docker 镜像 android-ndk-r21b
Github版本:
Github Version:
下载时间:2020/07/02 MNN-1.0.0.zip
直接下载ZIP包请提供下载日期以及压缩包注释里的git版本(可通过7z l zip包路径命令并在输出信息中搜索Comment 获得,形如Comment = bc80b11110cd440aacdabbf59658d630527a7f2b)。 git clone请提供 git commit 第一行的commit id
Provide date (or better yet, git revision from the comment section of the zip. Obtainable using 7z l PATH/TO/ZIP and search for Comment in the output) if downloading source as zip,otherwise provide the first commit id from the output of git commit
编译方式:
Compiling Method
~/yw/MNN/project/android/build32# ../build_32.sh -DMNN_OPENCL=ON -DMNN_VULKAN=ON
编译日志:
Build Log:
-- android-14 is unsupported. Using minimum supported version 16.
-- The ASM compiler identification is Clang
-- Found assembler: /root/yw/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /root/yw/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /root/yw/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /root/yw/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /root/yw/ndk/android-ndk-r21b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /root/anaconda3/bin/python (found version "3.7.6")
-- >>>>>>>>>>>>>
-- MNN BUILD INFO:
-- System: Android
-- Processor: armv7-a
-- Metal: OFF
-- OpenCL: ON
-- OpenGL: OFF
-- Vulkan: ON
-- ARM82: OFF
-- OpenMP: OFF
-- Hidden: TRUE
-- Build Path: /root/yw/MNN/project/android/build32
-- Enabling AArch32 Assemblies
-- Configuring done
-- Generating done
-- Build files have been written to: /root/yw/MNN/project/android/build32
Scanning dependencies of target MNNCompute
Scanning dependencies of target MNNARM32
Scanning dependencies of target MNNShape
Scanning dependencies of target MNNCPU
[ 0%] Building ASM object CMakeFiles/MNNARM32.dir/source/backend/cpu/arm/arm32/MNNAddBias.S.o
...
...
...
[ 73%] Building CXX object source/backend/vulkan/CMakeFiles/MNN_Vulkan.dir/compiler/AllShader.cpp.o
/root/yw/MNN/source/backend/vulkan/compiler/AllShader.cpp:3:1: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
const
^~~~~~
/root/yw/MNN/source/backend/vulkan/compiler/AllShader.cpp:112:1: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
const
^~~~~~
...
...
...
/root/yw/MNN/source/backend/vulkan/compiler/AllShader.cpp:112:7: error: expected unqualified-id
const
^
110 warnings and 1 error generated.
source/backend/vulkan/CMakeFiles/MNN_Vulkan.dir/build.make:95: recipe for target 'source/backend/vulkan/CMakeFiles/MNN_Vulkan.dir/compiler/AllShader.cpp.o' failed
make[2]: *** [source/backend/vulkan/CMakeFiles/MNN_Vulkan.dir/compiler/AllShader.cpp.o] Error 1
CMakeFiles/Makefile2:700: recipe for target 'source/backend/vulkan/CMakeFiles/MNN_Vulkan.dir/all' failed
make[1]: *** [source/backend/vulkan/CMakeFiles/MNN_Vulkan.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
...
...
...
[ 84%] Linking CXX shared library ../../../libMNN_CL.so
[ 85%] Built target MNN_CL
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
此外,使用由MNN源码编译的Linux端 libMNN_CL.so 和 libMNN_Vulkan.so 库在后端推理时出现如下问题: 使用 libMNN_CL.so 执行后端推理: 参照了 https://github.com/alibaba/MNN/issues/105#issuecomment-499396934 https://github.com/alibaba/MNN/issues/310#issue-492068093
运行结果:
ERROR CODE : -52
ERROR CODE : -52
ERROR CODE : -52
使用 libMNN_Vulkan.so 执行后端推理: 参照了 https://github.com/alibaba/MNN/issues/127
运行结果:
Can't Find type=7 backend, use 0 instead
请问上述问题有什么解决的思路/方法吗? PS:修改类似 XXXbuild.sh 中 opencl 或 vulkan 的方式进行编译 和 直接使用XXXbuild.sh -DMNN_OPENCL=ON -DMNN_VULKAN=ON 两种方式在执行时可能产生不同的结果。
使用最新MNN库后,android 端编译问题消失。 Linux端 执行推理问题依旧。
是运行 opencl 推理出错,还是无法启用 opencl?
是运行 opencl 推理出错,还是无法启用 opencl?
我认为是运行 opencl 推理出错,应该和 https://github.com/alibaba/MNN/issues/310#issue-492068093 中的错误是一样的。 但参考链接中并没有说明原因和解决方案。
../build_32.sh -DMNN_OPENCL=ON ../build_32.sh -DMNN_VULKAN=ON
分开编译没有问题,只启动一种编译方式 opengl/opencl/vulkan
../build_32.sh -DMNN_OPENCL=ON ../build_32.sh -DMNN_VULKAN=ON
分开编译没有问题,只启动一种编译方式 opengl/opencl/vulkan
编译问题解决了。感谢。
是运行 opencl 推理出错,还是无法启用 opencl?
我认为是运行 opencl 推理出错,应该和 #310 (comment) 中的错误是一样的。 但参考链接中并没有说明原因和解决方案。
请问你的问题解决没有,我也遇到了相似问题。Failed creating base context during opening of kernel driver. Kernel module may not have been loaded Build program failed ! programName.c_str()=s buffer_to_image in buildKernel, 305 ERROR CODE : -44