Delegate creation failure

I’m using tensor flow 2.1.0 and I would like to add a GPU implementation.
Without GPU, everything works fine. However, I have some issues with creating a delegate.

Delegate = TfLiteGpuDelegateCreate(nullptr);
auto res = Interperter->ModifyGraphWithDelegate(Delegate);

After that - res != kTfLiteOk (res equals 1 instead).

Can you please support?


Do you have a specific reason for using TF 2.1? If not, please use the latest version TF 2.10 to
create the delegate with TfLiteGpuDelegateV2Create()

// NEW: Prepare GPU delegate.
auto* delegate = TfLiteGpuDelegateV2Create(/*default options=*/nullptr);
if (interpreter->ModifyGraphWithDelegate(delegate) != kTfLiteOk) return false;

Verify if your device indeed has a supported SoC. Run adb shell cat /proc/cpuinfo | grep Hardware

Enable GPU support by rooting adb shell setenforce 0

Thank you

Please refer to Build from Source and GPU acceleration delegate. Thank you

In TF 2.10, the commands to build GPU delegates are as shown below for android arm64.

bazel build -c opt --config android_arm64 tensorflow/lite/delegates/gpu:delegate        # for static library
bazel build -c opt --config android_arm64 tensorflow/lite/delegates/  # for dynamic library

You can choose other flags armv7, armv8 as per your android architecture.

Once you build a delegate you have to add the delegate through the interpreter option. Thank you!