-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
TypeError: Cannot read property 'backend' of undefined - tensor is already disposed when moveData is called. #4237
Comments
@rthadur Thanks for the reply. Unfortunately, reproducing it in codepen will be extremely challenging because this is a bug in the Node.js version of Tensorflow.js - NOT the browser version. I can certainly provide an isolated Node.js test case instead, but I seriously doubt that a browser test case is going to help anyone debug this issue at all. |
An isolated node.js test case would be great! Thanks |
Sure thing, @tafsiri! Ok, so it's taken me a while (I couldn't reproduce it for a moment), but here's a link to an isolated test case: https://ybin.me/p/a1270fe449cdf849#ytc4MN1kBD9FJvUHsV3hDr7fYflYxY9ny1+suX75FZg= Instructions:
A recent version of Node.js is required (I'm using v15.1.0), because I'm using the ES6 module syntax. |
I think I've traced this down to an issue in tf.data.generator and how you are using it in this instance. The core issue is that you are passing the same tensor references as part of multiple input/label tuples. Internally at some point tf will dispose of the tensor once it has been consumed from the generator. Here is a workaround: // in process_data()
yield {
xs: last.clone(),
ys: next.clone()
}; Adding .clone() to the tensor that you yield to the generator will ensure each gets a new id and object reference and will prevent early garbage collection. |
Ah, thanks so much! That seems to have fixed it :D :D :D Is there a way to patch Tensorflow.js to generate a more useful error message in circumstances like these (e.g. if a Tensor doesn't exist, then throwing a nice error to tell the developer about this), or should I just close this issue? |
You can leave it open for now. We can discuss internally what the best solution might be (there are a number of different places we may want to tackle this). I'm going to update the title for when we get a chance to look more closely at this. |
This is really useful to know if you're using React & Refs. |
Thanks! I look forward to further news about this. |
If this helps as further input to this bug, I got the same error but it went away after I removed the tf.tidy(() => { }) wrapper around where I was building a model, and calling .compile, and .fit. tensorflow.js was also using webGl I'll continue to not use tf.tidy for now, but not sure if this is going to cause memory leaks due to (as I understand it) tensorflow managing tensors on my GPU -- otherwise I guess I could back it off to use the CPU. |
Hi, @sbrl Apologize for the delayed response and May I know have you tried with latest version of @grmatthews, It seems like we have updated our official documentation for tf.tidy() so could you please try with latest version of If issue still persists please let us know ? Thank you! |
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. |
Closing as stale. Please @mention us if this needs more attention. |
Hey @gaikwadrahul8 , are there any news on this? The same issue seems to occure in tensorflowjs-node-gpu, but unfortunately I cant open the link to the test case @sbrl provided, so @joshuaellis answer is a little bit confusing to me. I have created a stackoverflow question, with code example, since there are other changes, that might be the source of my Problem, any suggestion would be very helpful. |
This backend issue took me hours to figure-out, as this only happed on my backend applications:
|
Has there been any progress on this? |
@jmullings thankss for your reply. I assume you are using the asyncGenerator with the tf.data.generator function to create a dataset? Unfortunateley this does not work in typescript:
It boiled down to this Problem:
So I ended up fetching all the examples before creating a dataset from them. This should not be necessary since I am using a batch number of 1 and only one example at a time is being processed. Or there is something I am getting wrong? ... |
I'm trying to setup an LSTM, but Tensorflow.js doesn't seem to like it very much. It keeps crashing with the following error:
Is there any reason for this? I've double-checked all my tensors going in, and they all contain valid data.
System details:
@tensorflow/tfjs-node
= 2.7.0,@tensorflow/tfjs-node-gpu
= 2.7.0Model summary:
Options objects for the 3 layers:
The dataset is created by passing
Uint8Array
instances totf.tensor
, which are themselves views of a mainArrayBuffer
.Training code:
...full code available upon request.
The text was updated successfully, but these errors were encountered: