javacpp-presets icon indicating copy to clipboard operation
javacpp-presets copied to clipboard

Building tensorflow lite GPU

Open barrypitman opened this issue 6 months ago • 6 comments

Hi,

I'm trying to build tensorflow lite for linux-x86_64 with the -gpu extension. I figured that the easiest way would be to use GitHub actions and just modify some of the workflow files, which I've done here - https://github.com/bytedeco/javacpp-presets/compare/master...barrypitman:javacpp-presets:v1.5.10-GPU

I was initially able to build the tensorflow-lite-2.15.0-1.5.10-linux-x86_64-gpu.jar file by passing ext=-gpu. The resulting libjnitensorflowlite.so file is larger than the default one without GPU support (seems like a good thing).

However, when I try to include that tensorflow-lite-2.15.0-1.5.10-linux-x86_64-gpu.jar file in my project as a dependency, I can't call create the GPU delegate, e.g. "TfLiteGpuDelegateV2Create" as described here - https://www.tensorflow.org/lite/android/delegates/gpu_native#enable_gpu_acceleration. The class doesn't exist.

Then I tried to link the relevant header files to generate the necessary java classes, i.e.

@Platform(
                value = {"android", "linux"},
                extension = "-gpu",
                define = "UNIQUE_PTR_NAMESPACE std",
                include = {
                        "tensorflow/lite/delegates/gpu/delegate.h",
                        "tensorflow/lite/delegates/gpu/delegate_options.h",
                }

But that caused the build to fail with a lot of compilation errors - https://github.com/barrypitman/javacpp-presets/actions/runs/10420729781/job/28861326724

Any tips or pointers for how to build the linux-x86_64 version of tensorflow lite with GPU support would be appreciated!

Thanks

barrypitman avatar Aug 16 '24 14:08 barrypitman