-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
[Android][iOS] Loading Model from local file with GPUDelegate fails to load #84
Comments
Guten Tag, Hans here. It looks like your issue is not entirely clear and doesn't provide enough details for mrousavy to help you effectively. You mention an error loading the model with GPUDelegate but didn't share how to reproduce it without that argument, nor did you provide the specific environment details like your React Native version, TensorFlow Lite version, etc. Please ensure that you follow the issue template, including pasting all relevant logs from Android (adb logcat captures must be provided) and other necessary info. This will help mrousavy a lot! For a quicker resolution, consider sponsoring the project here 🍻.
|
I have added logs to initial post. |
From the log, it likely due to the device cannot import OpenCL correctly. Did you try to include the following in AndroidManifest.xml as mentioned in docs <uses-native-library android:name="libOpenCL.so" android:required="false" />
<!--- depends on device you may need this too --->
<uses-native-library android:name="libOpenCL-pixel.so" android:required="false" /> |
I am using Expo so I don't have a direct AndroidManifest. I need to look at how to achieve this. |
Oh ya, it currently can only be achieved by prebuild sadly, but I think it is possible to have it in expo config plugin as a new feature pr. |
@TkTioNG This is what I have come up with, but something doesn't seem to be working: // Define the library names you want to add to the AndroidManifest.xml
const nativeLibraries = [
'libOpenCL.so',
'libOpenCL-pixel.so',
'libGLES_mali.so',
'libPVROCL.so',
];
module.exports = function withUsesNativeLibrary(config) {
return withAndroidManifest(config, config => {
const { modResults } = config;
if (
!Array.isArray(modResults.manifest.application?.['uses-native-library'])
) {
modResults.manifest.application['uses-native-library'] = [];
}
// Add each native library entry
nativeLibraries.forEach(libraryName => {
const hasLib = modResults.manifest.application[
'uses-native-library'
].some(lib => {
return lib['$']['android:name'] === libraryName;
});
if (!hasLib) {
modResults.manifest.application['uses-native-library'].push({
$: {
'android:name': libraryName,
'android:required': 'false',
},
});
}
});
// console.log(modResults.manifest.application['uses-native-library']); ==> seems OK here?
return config;
});
}; If I log [
{
'$': { 'android:name': 'libOpenCL.so', 'android:required': 'false' }
},
{
'$': {
'android:name': 'libOpenCL-pixel.so',
'android:required': 'false'
}
},
{
'$': { 'android:name': 'libGLES_mali.so', 'android:required': 'false' }
},
{
'$': { 'android:name': 'libPVROCL.so', 'android:required': 'false' }
}
] So it seems like it's there, but when I log the full config when running the app, it's not there, so is it being stripped out? Am I handling adding it to the config correctly? Does the |
I am seeing this issue on ios also now:
If I remove, it loads fine...working to get reproducible example
|
I have updated the title of this issue, and added iOS logs to the original description, as I am now able to replicate the issue on iOS too. Here is a simplified repo that shows how to see the error: https://github.com/lucksp/test-tflite-model |
@mrousavy I don't know why but this bot closed the issue just now, after I provided more details & repo? |
yea sorry the bot isn't very smart |
On both Apple & Android, when I load the model from local file with GPUDelegate passed in, the result is an error:
- on iOS it is fineHere is my code:
If I remove the 2nd argument of the model loader, then it works fine.
I am on Android 13, which I thought is supported per docs ??
adb logcat
:I have since added a repo as noted in comment below
The text was updated successfully, but these errors were encountered: