Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS MetalDelegate exception #152

Open
CaptainDario opened this issue Sep 10, 2021 · 2 comments
Open

iOS MetalDelegate exception #152

CaptainDario opened this issue Sep 10, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation iOS

Comments

@CaptainDario
Copy link

Hello,

when I try to use the MetalDelegate on an iPad pro 12.9 2017 I am getting an exception.
With creating an interpreter like this:

    final gpuDelegate = GpuDelegate(
      options: GpuDelegateOptions(
          allowPrecisionLoss: true, waitType: TFLGpuDelegateWaitType.active),
    );
    var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegate);
    return await Interpreter.fromAsset(_interpreterAssetPath,
        options: interpreterOptions);

The following exception is thrown

Unhandled Exception: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, TFLGpuDelegateCreate): symbol not found)

The full output:

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, TFLGpuDelegateCreate): symbol not found)

#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:31:29)
#1      tflGpuDelegateCreate
package:tflite_flutter/…/delegates/metal_delegate.dart:18
#2      tflGpuDelegateCreate (package:tflite_flutter/src/bindings/delegates/metal_delegate.dart)
package:tflite_flutter/…/delegates/metal_delegate.dart:1
#3      new GpuDelegate
package:tflite_flutter/…/delegates/metal_delegate.dart:25
#4      DrawingInterpreter._gpuInterpreterIOS
package:da_kanji_mobile/…/core/DrawingInterpreter.dart:292
#5      DrawingInterpreter._initInterpreterIOS
package:da_kanji_mobile/…/core/DrawingInterpreter.dart:262
<asynchronous suspension>
#6      DrawingInterpreter.init
package:da_kanji_mobile/…/core/DrawingInterpreter.dart:102
<asynchronous suspension>

Any help with this would be greatly appreciated.

@am15h the README is out of date in regards to creating a Metal delegate interpreter.
The parameters I am using became optional.

@CaptainDario
Copy link
Author

As mentioned in #100 one needs to build TF Lite for iOS from source to get the MetalDelegate working.
However it is not possible for me to build TF Lite from source.

@am15h would it be possible for you to provide a Metal enabled version for this plugin?

@CaptainDario
Copy link
Author

Maybe it would be nice to include that in the README too.

Like:

iOS

  • Download TensorFlowLiteC.framework (CPU inference only!).
    • If you want Metal Delegate support or want to build a custom version of tensorflow, follow instructions in wiki.
  • run dart pub get
  • Place the TensorFlowLiteC.framework in the pub-cache folder of this package.

Pub-Cache folder location: (ref)

~/.pub-cache/hosted/pub.dartlang.org/tflite_flutter-<plugin-version>/ios/ (Linux/ Mac)
%LOCALAPPDATA%\Pub\Cache\hosted\pub.dartlang.org\tflite_flutter-<plugin-version>\ios\ (Windows)

@am15h am15h added documentation Improvements or additions to documentation iOS labels Mar 6, 2022
@am15h am15h reopened this Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation iOS
Projects
None yet
Development

No branches or pull requests

2 participants