Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use GpuDelegateFactory.Options?

nice to meet you.

i tried to "GPU acceleration delegate for Android" refrence in tensorflow. [https://www.tensorflow.org/lite/android/delegates/gpu#java_1]

but, i can't running this code.

import org.tensorflow.lite.Interpreter;
import org.tensorflow.lite.gpu.CompatibilityList;
import org.tensorflow.lite.gpu.GpuDelegate;

// Initialize interpreter with GPU delegate
Interpreter.Options options = new Interpreter.Options();
CompatibilityList compatList = CompatibilityList();

if(compatList.isDelegateSupportedOnThisDevice()){
    // if the device has a supported GPU, add the GPU delegate
    GpuDelegate.Options delegateOptions = compatList.getBestOptionsForThisDevice();
    GpuDelegate gpuDelegate = new GpuDelegate(delegateOptions);
    options.addDelegate(gpuDelegate);
} else {
    // if the GPU is not supported, run on 4 threads
    options.setNumThreads(4);
}

Interpreter interpreter = new Interpreter(model, options);

// Run inference
writeToInput(input);
interpreter.run(input, output);
readFromOutput(output);

Because in tensorflow 2.10.0 is not supported "GpuDelegate.Options".

they said "Use GpuDelegateFactory.Options instead", but i can't generate GpuDelegateFactory.Options class.

i can't find it in "org.tensorflow:tensorflow-lite-gpu:2.10.0"..

i considered to use under 2.9.0 version but it's not matched my model version.

how to generate GpuDelegateFactory.Options? i need your help.

thanks.

like image 591
HNL Avatar asked Oct 22 '25 20:10

HNL


1 Answers

Add the following line to gradle seems to resolve the issue implementation 'org.tensorflow:tensorflow-lite-gpu-api:2.10.0'

See more details here https://github.com/tensorflow/tensorflow/issues/57934

like image 68
vutha Avatar answered Oct 27 '25 06:10

vutha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!