Optimum Exporter TFLite error

Hello,
I’m currently trying to export my Distilbert model to TFLite using the Optimum-cli :

optimum-cli export tflite --model my_model_path --task ‘text-classification’ --sequence_length 128 tflite_directory_path

It’s a DistilbertForSequenceClassification model

2023-05-17 10:18:29.684852: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 AVX512F AVX512_VNNI FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-05-17 10:18:29.828933: I tensorflow/core/util/util.cc:169] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2023-05-17 10:18:29.866055: E tensorflow/stream_executor/cuda/cuda_blas.cc:2981] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
/databricks/python/lib/python3.9/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.5
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
Traceback (most recent call last):
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-2050d359-7326-4f12-b563-0e4d5ea5bbe7/bin/optimum-cli", line 8, in <module>
    sys.exit(main())
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-2050d359-7326-4f12-b563-0e4d5ea5bbe7/lib/python3.9/site-packages/optimum/commands/optimum_cli.py", line 162, in main
    service = args.func(args)
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-2050d359-7326-4f12-b563-0e4d5ea5bbe7/lib/python3.9/site-packages/optimum/commands/base.py", line 90, in defaults_factory
    return self.__class__(
TypeError: __init__() got multiple values for argument 'parser'

Hi @aroger! Indeed I got the same error. We are going to look into it.

In the meantime, you can export your model to TFLite with the following command:

python3 -m optimum.exporters.tflite --model my_model_path --task text-classification --sequence_length 128 tflite_directory_path

@aroger We just released a patch, could you upgrade Optimum with pip install --upgrade optimum and try again please?

1 Like

Hi @regisss, imma try it today. i keep you in touch.
Thank you for the replies

@regisss, ça fonctionne désormais! merci

1 Like