Skip to content
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

TF while loop error #52

Open
akikaaa opened this issue Jan 8, 2021 · 1 comment
Open

TF while loop error #52

akikaaa opened this issue Jan 8, 2021 · 1 comment

Comments

@akikaaa
Copy link

akikaaa commented Jan 8, 2021

I'm trying to apply this awesome tool on BERT model. But it seems doesn's work with TF while loop. The model code is basically same as https://github.com/CLUEbenchmark/CLUENER2020/blob/master/tf_version/modeling.py, except that I add every sqrt(num_hidden_layers) hidden to collections by tf.add_to_collection('checkpoints', layer_output) . When run training, I got this error message: "ValueError: Cannot use 'loss/rnn/while/TensorArrayReadV3/Enter' as input to 'loss/rnn/while/TensorArrayReadV3_1' because 'loss/rnn/while/TensorArrayReadV3/Enter' is in a whileloop. See info log for more details." Would you please help me solve this problem?

@SeaOfOcean
Copy link

SeaOfOcean commented Mar 9, 2022

We have fixed the while_loop error in easy parallel library(EPL): https://github.com/alibaba/EasyParallelLibrary

you can enable gradient checkpoint by

import epl
epl.init(epl.Config({"gradient_checkpoint.type": "collection"}))
epl.set_default_strategy(epl.replicate(1))

model_with_checkpoint()

you can try gradient checkpoint "auto" selection, EPL auto find the entrance of each layer as checkpoint tensors

import epl
epl.init(epl.Config({"gradient_checkpoint.type": "auto"}))
epl.set_default_strategy(epl.replicate(1))

model()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants