英文:
Tensorflow 2.X Error - Op type not registered 'CaseFoldUTF8' in binary running on Colab
问题
我一直在使用来自Tensorflow Hub的BERT编码器已经有一段时间了。以下是语法:
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)
突然间,我遇到了这个错误消息:
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.resampler' should 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 the 'experimental_io_device' option in 'tf.saved_model.LoadOptions' to the io_device such as '/job:localhost'.
相同的代码已经运行了好几年了。TensorFlow版本 - 2.9,环境 - Colab / GCP Vertex AI。
英文:
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.
experimental_io_device
You may be trying to load on a different device from the computational device. Consider setting theoption in
tf.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
答案1
得分: 4
导入import tensorflow_text as text
应该解决这个问题。
编辑:你可能需要在Colab中运行 !pip install tensorflow_text
。
英文:
Importing import tensorflow_text as text
should solve this issue.
Edit: You might have to run !pip install tensorflow_text
in Colab.
答案2
得分: 1
这个模糊的错误消息是在调用编码器之后导入tensorflow_hub包导致的。当我将导入语句放在调用编码器之前时,问题得以解决。
英文:
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.
答案3
得分: 0
2 years ago, I trained model in google colab than compressed it into a zip file
some days ago, I trained that model again (with other train data) in google colab, ran it with the same code then I encountered this error
I extracted the zip file from 2 years ago, ran it with the same code, everything is fine
so I guess, you need be sure that version of tensorflow you use to trained model is the same with it in the past
英文:
2 years ago, I trained model in google colab than compressed it into a zip file
some days ago, I trained that model again (with other train data) in google colab, ran it with the same code then I encountered this error
I extracted the zip file from 2 years ago, ran it with the same code, everything is fine
so I guess, you need be sure that version of tensorflow you use to trained model is the same with it in the past
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论