iOS MetalDelegate exception
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.
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?
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)