tensorflow / tfjs

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

Problem during installation for React Native #4475

Closed Junhano closed 3 years ago

Junhano commented 3 years ago

So I try to install Tensorflow on my React Native app but after installing all the required dependency it return some errors on my IOS phone

The kernel 'undefined' for backend 'cpu' is already registered
The kernel 'undefined' for backend 'webgl' is already registered
The "UMNativeModulesProxy" native module is not exported through NativeModules; verify that @unimodules/react-native-adapter's native code is linked properly
 TypeError: null is not an object (evaluating 'NativeUnimoduleProxy.viewManagersNames')
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

That's my package.json

"dependencies": {
    "@react-native-community/async-storage": "^1.12.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.7",
    "@react-native-community/picker": "^1.6.6",
    "@tensorflow-models/posenet": "^2.2.1",
    "@tensorflow/tfjs-backend-cpu": "^2.8.2",
    "@tensorflow/tfjs-backend-webgl": "^2.8.2",
    "@tensorflow/tfjs-converter": "^2.7.0",
    "@tensorflow/tfjs-core": "^2.7.0",
    "@tensorflow/tfjs-react-native": "^0.5.0",
    "@unimodules/core": "^6.0.0",
    "@unimodules/react-native-adapter": "^5.7.0",
    "expo-asset": "^8.2.1",
    "expo-camera": "^9.1.1",
    "expo-constants": "^9.3.5",
    "expo-file-system": "^9.3.0",
    "expo-gl": "^9.2.0",
    "react": "16.13.1",
    "react-native": "^0.63.4",
    "react-native-camera": "^3.37.0",
    "react-native-cli": "^2.0.1",
    "react-native-elements": "^2.3.1",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "^1.8.0",
    "react-native-input-spinner": "^1.3.1",
    "react-native-localize": "^1.4.1",
    "react-native-reanimated": "^1.13.1",
    "react-native-screens": "^2.11.0",
    "react-native-vector-icons": "^7.0.0",
    "react-redux": "^7.2.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "unimodules-permissions-interface": "^5.4.0"
  },

I make sure I did pod install as well. Also side questions. I don't use expo for my app at all. Do I still need to install those dependency to make Tensorflowjs work?

rthadur commented 3 years ago

i don't think you need tfjs-converter and tfjs-core in dependencies , please refer here for package.json https://github.com/tensorflow/tfjs/blob/master/tfjs-react-native/package.json cc @tafsiri

tafsiri commented 3 years ago

@Junhano It looks like you might be missing a step in the installation of unimodules, did you go through everything here? https://github.com/tensorflow/tfjs/tree/master/tfjs-react-native#step-2-install-dependencies

To answer your other question, yes you still need to install those dependencies outside of an expo based app.

Junhano commented 3 years ago

Ok So I reinstall many module and the app start now. However it still shows The kernel 'undefined' for backend 'cpu' is already registered The kernel 'undefined' for backend 'webgl' is already registered These two warnings

tafsiri commented 3 years ago
"@tensorflow/tfjs-backend-cpu": "^2.8.2",
"@tensorflow/tfjs-backend-webgl": "^2.8.2",
"@tensorflow/tfjs-converter": "^2.7.0",
"@tensorflow/tfjs-core": "^2.7.0",

I think you want these to all be the same version (either 2.7.0 or 2.8.2)

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

Are you satisfied with the resolution of your issue? Yes No