OpenNMT

Convert OpenNMT-TF model to CTranslate2

Model was created a some years ago. Now we trying to convert it to Ctranslate. but

2021-07-07 09:25:18.869782: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcudart.so.11.0
Traceback (most recent call last):
File “/root/.local/share/virtualenvs/r10-MnTosGMW/bin/ct2-opennmt-tf-converter”, line 8, in
sys.exit(main())
File “/root/.local/share/virtualenvs/r10-MnTosGMW/lib/python3.8/site-packages/ctranslate2/converters/opennmt_tf.py”, line 355, in main
OpenNMTTFConverter(
File “/root/.local/share/virtualenvs/r10-MnTosGMW/lib/python3.8/site-packages/ctranslate2/converters/converter.py”, line 31, in convert_from_args
return self.convert(
File “/root/.local/share/virtualenvs/r10-MnTosGMW/lib/python3.8/site-packages/ctranslate2/converters/converter.py”, line 45, in convert
model_spec = self._load()
File “/root/.local/share/virtualenvs/r10-MnTosGMW/lib/python3.8/site-packages/ctranslate2/converters/opennmt_tf.py”, line 78, in _load
version, variables = load_model(self._model_path)
File “/root/.local/share/virtualenvs/r10-MnTosGMW/lib/python3.8/site-packages/ctranslate2/converters/opennmt_tf.py”, line 17, in load_model
raise RuntimeError(
RuntimeError: Converting the SavedModel format is not supported, please convert a TensorFlow checkpoint instead

model dir
.
├── assets
│ ├── en.spm.vocab
│ └── nl.spm.vocab
├── en.spm.model
├── nl.spm.model
├── saved_model.pb
└── variables
├── variables.data-00000-of-00002
├── variables.data-00001-of-00002
└── variables.index

does anybody know what hapend

The error message says exactly what is happening:

If you no longer have the checkpoint around, you can downgrade to a previous version of CTranslate2 which still supported the conversion of the SavedModel format:

pip install ctranslate2==1.*

do you mean tensorflow instead of ctranslate2?

import tensorflow as tf
if tf.saved_model.contains_saved_model(model_path):
        raise RuntimeError(
            "Converting the SavedModel format is not supported, "
            "please convert a TensorFlow checkpoint instead"
        )

No, I meant CTranslate2. We recently removed the capability to convert the SavedModel format.

understood
thx