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

Clarify why TextVectorization works on CPU #913

Merged
merged 2 commits into from
Jun 15, 2022
Merged

Clarify why TextVectorization works on CPU #913

merged 2 commits into from
Jun 15, 2022

Conversation

8bitmp3
Copy link
Contributor

@8bitmp3 8bitmp3 commented Jun 13, 2022

As discussed with @fchollet @mattdangerw @MarkDaoust

This PR introduces the following improvements:

  • Clarify that the Keras TextVectorization layer should be used as part of a tf.data input pipeline (runs only on CPUs, won't utilize hardware acceleration if included inside a Model, affecting performance).
  • Perform some minor linting.

Copy link
Contributor

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR. Please regenerate the ipynb and md files.

Copy link
Member

@mattdangerw mattdangerw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -614,6 +638,7 @@ print("Model output:", test_output)

<div class="k-default-codeblock">
```
WARNING:tensorflow:5 out of the last 1567 calls to <function PreprocessingLayer.make_adapt_function.<locals>.adapt_step at 0x7f80ec464a60> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has reduce_retracing=True option that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for more details.
Copy link
Contributor Author

@8bitmp3 8bitmp3 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattdangerw @fchollet Note the warnings in the output after regenerating .md and Jupyter files

Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
170498071/170498071 [==============================] - 14s 0us/step

2022-06-15 15:02:40.512792: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 153600000 exceeds 10% of free system memory.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattdangerw @fchollet Maybe we should make the output in cells less verbose.

@@ -116,6 +116,14 @@ print("Features std: %.2f" % (normalized_data.numpy().std()))

<div class="k-default-codeblock">
```
2022-06-15 15:02:07.223345: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
Copy link
Contributor Author

@8bitmp3 8bitmp3 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattdangerw @fchollet Note the new messages in the output after regenerating the notebook and Markdown files

Copy link
Contributor

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll remove the warnings in post. Thanks!

@fchollet fchollet merged commit d334493 into keras-team:master Jun 15, 2022
@8bitmp3 8bitmp3 deleted the update-workingwithkpls-textvectorization branch June 16, 2022 11:17
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

Successfully merging this pull request may close these issues.

3 participants