RK3588 确认 OpenCL 是否可用(前提,使用的Opencv 是已经确认编译好,使用OpenCL 版本的)

参考链接

【Setting up OpenCL on RK3588 using libmali】:Setting up OpenCL on RK3588 using libmali - Martin's website/blog thingy

【rk3588在docker内使用opencl报错】: rk3588在docker内使用opencl报错 · Issue #316 · rockchip-linux/kernel · GitHub

【rk3588 opencv如何通过opencl启动GPU加速】: https://wenku.csdn.net/answer/697ef1dd559245f6937bc5ade3c1f6be

当确认使用的 Opencv 是开启了 OpenCL 后,使用下面的代码进行测试

注意: 在RK3588 上不一定能查看到,并且大概率会提示报错:

arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'. Failed creating base context during opening of kernel driver.

#include "opencv2/opencv.hpp"
#include "opencv2/core/ocl.hpp"
​
using namespace std;
using namespace cv;
using namespace cv::ocl;
​
int main()
{
    vector<ocl::PlatformInfo> info;
    getPlatfomsInfo(info);
    PlatformInfo sdk = info.at(0);
​
    if (sdk.deviceNumber()<1)
        return -1;
​
    cout << "******SDK*******" << endl;
    cout << "Name: " << sdk.name() << endl;
    cout << "Vendor: " << sdk.vendor() << endl;
    cout << "Version: " << sdk.version() << endl;
    cout << "Number of devices: " << sdk.deviceNumber() << endl;
​
    for (int i=0; i<sdk.deviceNumber(); i++){
        Device device;
        sdk.getDevice(device,i);
        cout << "\n\n*********************\n Device " << i+1 << endl;
​
        cout << "Vendor ID: " << device.vendorID() << endl;
        cout << "Vendor name: " << device.vendorName() << endl;
        cout << "Name: " << device.name() << endl;
        cout << "Driver version: " << device.driverVersion() << endl;
        if (device.isAMD()) cout << "Is an AMD device" << endl;
        if (device.isIntel()) cout << "Is a Intel device" << endl;
        cout << "Global Memory size: " << device.globalMemSize() << endl;
        cout << "Memory cache size: " << device.globalMemCacheSize() << endl;
        cout << "Memory cache type: " << device.globalMemCacheType() << endl;
        cout << "Local Memory size: " << device.localMemSize() << endl;
        cout << "Local Memory type: " << device.localMemType() << endl;
        cout << "Max Clock frequency: " << device.maxClockFrequency() << endl;
    }
​
    return 0;
}

或者使用 clinfo 命令查看

大概率会出现下面的报错:

arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'. Failed creating base context during opening of kernel driver.

注意

如果出现了报错

Failed creating base context during opening of kernel driver.

先不要急, 有以下两种可能:

  • 和网络上大多数查看的文章一致, 没有设置好驱动

  • 没有内核开启权限(我就是这种情况)

解决方法
没有权限

这个方式是最简单的,只需要在命令加上 sudo 就可以了

没设置好驱动

参考链接:

【Setting up OpenCL on RK3588 using libmali】:Setting up OpenCL on RK3588 using libmali - Martin's website/blog thingy

【OpenCL学习笔记(四)手动编译开发库(ubuntu+gcc+rk3588)】:OpenCL学习笔记(四)手动编译开发库(ubuntu+gcc+rk3588)_3588 opencl-CSDN博客

先安装驱动,或者找到自己板子上的驱动(因为 github 上的issue提到,RK3588 使用的 GPU 访问路径是 /dev/mali0,所以文件名大概率会包含 mali【个人猜测】)

使用下面命令,查看是否本身就有驱动

sudo find / -name "*OpenCL*"

如果没有,则使用下面命令(按照上面提到的文章【 Setting up OpenCL on RK3588 using libmali 】走一遍流程)

cd /usr/lib
sudo wget https://github.com/JeffyCN/mirrors/raw/libmali/lib/aarch64-linux-gnu/libmali-valhall-g610-g6p0-x11-wayland-gbm.so

注意:最主要是这一步——将so文件写入到 /etc/OpenCL/vendors/mali.icd 中(可能是因为 clinfo 查询的路径就是 /etc/OpenCL/vendors/mali.icd ?)

echo "/usr/lib/libmali-valhall-g610-g6p0-x11-wayland-gbm.so" | sudo tee /etc/OpenCL/vendors/mali.icd
# "/usr/lib/libmali-valhall-g610-g6p0-x11-wayland-gbm.so" 可以是你本地的 opencl 动态库路径

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值