Rosella       Machine Intelligence & Data Mining

HomeDataMining & Machine LearningProducts & DownloadsSite MapContact |

Install OpenCL on Debian and Ubuntu for Orange Pi 5

This page explains how to enable OpenCL on Debian (Bookworm) and Ubuntu (Jammy) for Orange Pi 5 Single Board Computers. OS images we tested are Debian and Ubuntu images from the Orange Pi 5 Home. Note that Ubuntu Jammy Gnome version can freeze mouse and screen often. So avoid it. Use Xfce version.

To enable OpenCL, take the following steps;
Note that some part of this information was derived from Setting up OpenCL on RK3588 using libmali. Download the ARM Mali GPU blob from rockchip's repository and put it into /usr/lib/ as follows. And install the firmware for the GPU if not already installed.

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

cd /lib/firmware
sudo wget https://github.com/JeffyCN/mirrors/raw/libmali/firmware/g610/mali_csffw.bin

Add the Mali GPU blob to the OpenCL ICD config file as follows;

sudo apt install mesa-opencl-icd clinfo

On Ubuntu, you may get not found errors, especially huawei links. Ignore them. It looks OK. Proceed with the followings;

sudo mkdir -p /etc/OpenCL/vendors
echo "/usr/lib/libmali-valhall-g610-g6p0-x11-wayland-gbm.so" | sudo tee /etc/OpenCL/vendors/mali.icd

Set the dependencies of the Mali OpenCL as follows;

sudo apt install libxcb-dri2-0 libxcb-dri3-0 libwayland-client0 libwayland-server0 libx11-xcb1

Now you can run "clinfo" to check whether OpenCL is working. You will see the following if OpenCL is installed correctly;

...> clinfo
Number of platforms                       1
  Platform Name                           ARM Platform
  Platform Vendor                         ARM
  Platform Version                        OpenCL 2.1 v1.g6p0-01eac0.2819f9d4dbe0b5a2f89c835d8484f9cd
  Platform Profile                        FULL_PROFILE
  Platform Extensions                     cl_khr_global_int32_base_atomics ...
  Platform Extensions function suffix     ARM
  Platform Host timer resolution          1ns
  ...

Check weather some dependencies are missing using ldd command as follows;

ldd /usr/lib/libmali-valhall-g610-g6p0-x11-wayland-gbm.so

Create Symbolic Link for libOpenCL.so

The directory "/usr/lib/aarch64-linux-gnu/" will have "libOpenCL.so.1.0.0". But no "libOpenCL.so" file. In this case, create a symbolic link as follows. You need to log into root account to create this, say, "su -";

cd /usr/lib/aarch64-linux-gnu/
ln -s libOpenCL.so.1.0.0 libOpenCL.so

Copying OpenCL "CL" Folder into "/usr/include"

Your "/usr/include/" directory may not have "CL" folder. In this case, you need to copy "CL" folder in this CL.zip file into the "/usr/include/" directory. Extract/copy "CL" folder into your convenient folder. Log into "root" account, say "su -". "cd" to your folder that has the copied "CL" folder. From there, copy it to "/usr/include" folder as follows;

cp -r CL /usr/include

Restart your Orange Pi 5.

Now you are ready to compile and run. Compile command example is as follows. Change as your need. CMake files can be adjusted accordingly.

g++ CMSRModel.cpp OpenclModel.cpp Main.cpp -L "/usr/lib/aarch64-linux-gnu/" -lOpenCL -o app