Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow 2.X Error - Op type not registered 'CaseFoldUTF8' in binary running on Colab

I have been using BERT encoder from the Tensorflow hub for quite sometime now. Here are the syntaxes:

tfhub_handle_encoder = "https://tfhub.dev/tensorflow/bert_multi_cased_L-12_H-768_A-12/4" tfhub_handle_preprocess = "https://tfhub.dev/tensorflow/bert_multi_cased_preprocess/3" bert_preprocess_model = hub.KerasLayer(tfhub_handle_preprocess)

All off a sudden I am encountering this error message: FileNotFoundError: Op type not registered 'CaseFoldUTF8' in binary running on acb9309ebd87. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resamplershould be done before importing the graph, as contrib ops are lazily registered when the module is first accessed. You may be trying to load on a different device from the computational device. Consider setting theexperimental_io_deviceoption intf.saved_model.LoadOptions to the io_device such as '/job:localhost'.

The same code has been running well for years now. Tf Version - 2.9, Environment - Colab/ GCP Vertex AI

like image 602
Yogesh_25 Avatar asked Sep 18 '25 20:09

Yogesh_25


2 Answers

Importing import tensorflow_text as text should solve this issue.

Edit: You might have to run !pip install tensorflow_text in Colab.

like image 109
Yajat Malhotra Avatar answered Sep 23 '25 05:09

Yajat Malhotra


This ambiguous error message is due to importing tensorflow_hub package after calling the encoder. The issue got resolved when I pushed the import statement before calling the encoder.

like image 39
Yogesh_25 Avatar answered Sep 23 '25 07:09

Yogesh_25



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!