tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.39k stars 1.92k forks source link

Error: Backend name 'rn-webgl' not found in registry #4630

Closed BhagwatSagar30 closed 3 years ago

BhagwatSagar30 commented 3 years ago

We are getting an error while setting the backend name as "rn-webgl" in react native.

Sample code of implementation.

import * as tf from "@tensorflow/tfjs";

await tf.setBackend("rn-webgl"); await tf.ready();

We are using the following version of the library. "expo-camera": "9.1.1", "expo-font": "^8.3.0", "expo-gl": "9.2.0", "expo-gl-cpp": "9.2.0", "expo-av": "^8.6.0", "@tensorflow-models/blazeface": "0.0.5", "@tensorflow-models/knn-classifier": "1.2.2", "@tensorflow-models/posenet": "2.2.1", "@tensorflow/tfjs": "2.7.0", "@tensorflow/tfjs-react-native": "0.5.0", "react": "16.13.1", "react-native": "0.63.3",

Please help with this.

Thanks in advance.

mattsoulanille commented 3 years ago

You'll need to import '@tensorflow/tfjs-react-native'; to use the rn-webgl backend. See here for an example.

sndkd commented 3 years ago

@mattsoulanille even i'm getting the same issue even after adding import '@tensorflow/tfjs-react-native'; It says Error: Backend name 'rn-webgl' not found in registry

If i remove the setBackend() function, then it throws different error TypeError: undefined is not an object (evaluating 'env().platform.fetch')

This stopped working from 2-3 days back in existing release builds

utills commented 3 years ago

@sndkd @mattsoulanille @rthadur did you find any solution for this ? I'm also facing the same issue from yesterday in iOS react native 0.63 Error: Backend name 'rn-webgl' not found in registry

BhagwatSagar30 commented 3 years ago

@mattsoulanille I'm still getting same error after adding import '@tensorflow/tfjs-react-native';

rthadur commented 3 years ago

Thank you all for your patience, we are investigating this and we will find more details soon. @BhagwatSagar30 can you try using latest tfjs-version ? @sndkd @utills can you please share your package.json ?

rthadur commented 3 years ago

Also if possible can you please look at these steps if applicable

  1. Is the app created using expo? If so is it a managed or bare app?
  2. Which version of react native and the dependencies in the install instructions are you using?
  3. What device(s) are you running on? Note that not all simulators support webgl and thus may not work with tfjs-react-native.
  4. What error messages are you seeing? Are there any relevant messages in the device logs?
  5. How could this bug be reproduced? Is there an example repo we can use to replicate the issue?
mattsoulanille commented 3 years ago

I'm having trouble reproducing this. Here's my test repo, where the backend loads properly. I've tested on an Android phone, but this might be iOS-specific. I'll try on an iOS simulator and let you know what I find.

mattsoulanille commented 3 years ago

I couldn't get the simulator working, so I tried on an iPhone SE running iOS 14.3. It worked there as well. Can you try the test repo on your device and let me know if it works? Thanks!

google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.

google-ml-butler[bot] commented 3 years ago

Closing as stale. Please @mention us if this needs more attention.

saaadshot commented 9 months ago

Does anyone got the error fixed? I am on @tensorflow/tfjs": "4.1.0", "@tensorflow/tfjs-react-native": "^1.0.0" and still facing the same issue