Search code examples
tensorflow2.0bert-language-model

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


Solution

  • 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.