cpu backend was already registered as global error

871 views
Skip to first unread message

greenrazer

unread,
Apr 21, 2018, 4:14:10 AM4/21/18
to TensorFlow.js Discussion
I tried building from the source tfjs-layers so I could see changes I have made to the code, however following this series of steps:

tfjs directory delete node-modules.
then in the tfjs-layers directory type `yarn link` then `yarn build`
then in the tfjs directory type `yarn link "@tensorflow/tfjs-layers"` then `yarn`
then in the tfjs directory running `yarn build-npm` and taking 'dist/tf.js' and using it in my browser

I get this error:
```
tf.js:25195 Uncaught Error: cpu backend was already registered as global
    at Environment.registerBackend (tf.js:25195)
    at Object.45.../environment (tf.js:13684)
    at s (tf.js:1)
    at tf.js:1
    at Object.126../environment (tf.js:22787)
    at s (tf.js:1)
    at tf.js:1
    at Object.44../browser_util (tf.js:12259)
    at s (tf.js:1)
    at tf.js:1
```
which seems to originate from these lines around line 22784 (tf.js)
```
var backend_cpu_1 = require("./kernels/backend_cpu");
var backend_webgl_1 = require("./kernels/backend_webgl");
```
if i delete these 2 lines i get this error
```
Uncaught Error: Tensor is disposed.
    at Tensor.throwIfDisposed (tf.js:22068)
    at Tensor.slice (tf.js:22131)
    at Object.qr (tf.js:569)
    at Orthogonal.apply (tf.js:6037)
    at LSTMCell.Layer.addWeight (tf.js:2611)
    at LSTMCell.build (tf.js:9172)
    at StackedRNNCells.build (tf.js:9540)
    at RNN.build (tf.js:8341)
    at tf.js:2525
    at Object.nameScope (tf.js:1785)
```
this error originates around 6034 (tf.js)
```
K.randomNormal(normalizedShape, 0, 1, types_1.DType.float32);
``
after calling tf.layers.rnn().apply() in this code roughly
```
    const inputs = tf.input({
      shape:[options.seqLength]
    });

    let cells = [];
    for(let i = 0; i < options.numLayers; i++) {
      const cell = tf.layers.lstmCell({
        units: options.hiddenSize
      });
      cells.push(cell);
    }

    tf.layers.rnn({
      cell: cells,
      returnSequences: true
    }).apply(inputs);

```
because isDisposed property is automatically set to true for some reason
I'm not sure if this is a bug or I have just set the project up incorrectly

Thanks for any help

Nikhil Thorat

unread,
Apr 23, 2018, 12:13:28 PM4/23/18
to greenrazer, TensorFlow.js Discussion

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+unsubscribe@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/c28b7ff4-5d82-4aee-a894-69c9bda00cac%40tensorflow.org.

Daniel Smilkov

unread,
Apr 23, 2018, 8:17:00 PM4/23/18
to Nikhil Thorat, kylebi...@gmail.com, TensorFlow.js Discussion
Hi,

npm/yarn link has issues with deduplication of peer dependencies. To work around this issue, we added a few scripts to package.json to help with this problem. See the section "Changing layers and testing tfjs" in tfjs-layers/DEVELOPMENT.md

Hope this helps!

Daniel


To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.

Jeff Pyke

unread,
Apr 27, 2018, 12:42:30 AM4/27/18
to TensorFlow.js Discussion, nsth...@google.com, kylebi...@gmail.com
Hi,

I'm having this same issue trying to use https://github.com/tensorflow/tfjs-converter. When I include both it and tfjs, I get "cpu backend was already registered" and "webgl backend was already registered" warnings, and when I try to create tensors, they are marked as isDisposed: true. I am doing pretty much the same thing as this demo https://github.com/tensorflow/tfjs-converter/tree/master/demo/mobilenet, which uses both tfjs-converter and tfjs-core, and having issues. Any help is appreciated. Thanks.
Message has been deleted
Message has been deleted
Message has been deleted

Jeff Pyke

unread,
Apr 27, 2018, 12:47:04 AM4/27/18
to TensorFlow.js Discussion, nsth...@google.com, kylebi...@gmail.com

Nikhil Thorat

unread,
Apr 27, 2018, 12:49:54 PM4/27/18
to Jeff Pyke, TensorFlow.js Discussion, greenrazer
Thanks for finding this, I made the fix and it should be out in the converter version 0.2.1!

Jeffrey Pyke

unread,
Apr 27, 2018, 1:12:03 PM4/27/18
to Nikhil Thorat, TensorFlow.js Discussion, greenrazer
Awesome, thanks!
Reply all
Reply to author
Forward
0 new messages