Edge offloading of semantic segmentation with dynamically selectable compression and local/remote processing. Includes remote server discovery.
This repository was used to produce results for the paper Jakub Žádník, Robin Bijl, Jan Solanti, Erno Joensuu, Markku Mäkitalo, Pekka Jääskeläinen, "Open Software Stack for Compression-Aware Adaptive Edge Offloading", in Proc. WCNC 2025.
clone the repo with its submodules with the following command:
git clone --recursive-submodules [email protected]:cs/cpc/aisa-demo.git
or initialize submodules after cloning with:
git submodule update --init --recursive
Android constantly updates packages and libraries that can break with newer versions. Below is a list of relevent versions currently used:
What | Version | where to check |
---|---|---|
Android Studio | Electric Eel (2022.1.1) | file > settings > appearance & behavior > system settings > updates |
JDK | 17 | file > project structure > SDK Location > gradle settings > gradle JDK |
Minimum SDK version | 24 | android/app/build.gradle > minSdk |
Targeted SDK version | 33 | android/app/build.gradle > targetSdk |
Gradle | 8.0 | file > project structure > project > gradle version |
Android Gradle plugin version | 8.0.2 | file > project structure > project > android gradle plugin version |
CMake | 3.22.1 | android/app/src/main/cpp/CMakeLists.txt > cmake_minimum_required |
NDK | 23.1.7779620 | (android layout in project tab) app/cpp/inlcudes/NDK |
C++ | 17 | android/app/build.gradle > cppFlags '-std=c++<version>' |
The smartphone application can be found in the android/
directory. Open and install it with Android Studio.
You should be able to run the semantic segmentation locally.
For remote inference, you need to build the server separately (see below) and add its IP address into the application.
The project requires installation of libraries inside the external
directory.
The Tracy profiler in external/tracy
is not required unless you plan to profile the application.
This project depends on a custom fork of an OpeCL implementation pocl, included in the external/pocl
directory.
To build the server, use the attached build_pocl_remote.sh
script (make sure to modify the paths as necessary).
To run the server, use run_pocl_remote.sh
(again adapting paths as necessary).
When the server is running, it is possible to offload computation to it by adding its IP address to the smartphone application.
Some phones provide a OpenCL library that can be used in C. This library needs to be whitelisted by the vendor. This can be checked like so:
- adb into the phone
- run:
and check that
cat /vendor/etc/public.libraries.txt
libOpenCL.so
is there
- install Android Studio
- install the android sdk from
Tools > SDK Manager > SDK Platforms
- install the android Native Development Kit (NDK) from
Tools > SDK Manager > SDK Tools
- install CMake from
Tools > SDK Manager > SDK Tools
follow the instructions in the scripts/build_opencv.bash
script
In order to build and run OpenCV and BiK, it is recommended to have the following variables set:
CUDA_VERSION='11.7'
CUDADIR="/usr/local/cuda-11.7"
CUDA_PATH="/usr/local/cuda-11.7"
CUDA_INSTALL_PATH="/usr/local/cuda-11.7"
LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:/lib/x86_64-linux-gnu
Of these LD_LIBRARY_PATH
is the most important.
While developing, there are a number of logging and debug variables that can be set. For poclImageProcessor.ccp
, "PRINT_PROFILE_TIME" can be defined.
On the java side, the DevelopmentVariables.java
contains variables that make the program more verbose
This is can happen after installing cuda-11-7. The ICD loader grabs the libopencl.so library that cuda-11.7
provides instead of the one from ocl-icd-libopencl1
. the easiest way to fix this is by moving the
libOpenCL.so*
files in /usr/local/cuda-11/lib64
into a new directory so that they won't be found.
This is the same issue as the previous troubleshooting case.
Add POCL_BUILDING=1
as a parameter as well.
If you get an error like this:
[ INFO:[email protected]] global onnx_importer.cpp:595 populateNet DNN/ONNX: loading ONNX v7 model produced by 'pytorch':2.0.0. Number of nodes = 297, inputs = 1, outputs = 2 OpenCV(4.7.0) Error: Assertion failed (blob_0.size == blob_1.size) in parseBias, file ./modules/dnn/src/onnx/onnx_importer.cpp, line 1067
make sure you built OpenCV and PoCL while having the LD_LIBRARY_PATH
environment variable set to contain:
/usr/local/cuda-11.7/lib64:/lib/x86_64-linux-gnu
in that order
- Use CPP files with
extern "C"
as the JNIEnv is different between C and CPP and the editer will have an issue with it otherwise.
Apache 2.0 license