keras-nlp icon indicating copy to clipboard operation
keras-nlp copied to clipboard

ModuleNotFoundError: No module named 'keras_nlp.api_export'

Open Alwaysadil opened this issue 2 years ago • 3 comments

ModuleNotFoundError: No module named 'keras_nlp.api_export'

Alwaysadil avatar Aug 23 '23 13:08 Alwaysadil

Can you give any more details?

A colab reproduction would be the most helpful.

mattdangerw avatar Aug 23 '23 19:08 mattdangerw

@mattdangerw actually my problem was related to download or install libtensorflowlite_gpu_delegate.so file in google colab and i am using tf version of 2.13.0 please help me to get that for adding that at tflite conversion for getting high performance(faster inference) i'm using this below code for tflite conversion import tensorflow as tf

Define your model and concrete function here

model_beam_search = ...

concrete_func = model_beam_search.call.get_concrete_function()

Create a TFLite converter and set the delegate to TfLiteGpuDelegate

converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func], model_beam_search) converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS] converter.optimizations = [tf.lite.Optimize.DEFAULT]

Replace TfLiteFlexDelegate with TfLiteGpuDelegate

gpu_delegate = tf.lite.experimental.load_delegate('libtensorflowlite_gpu_delegate.so') converter.experimental_new_converter = True  # This flag is needed for using the experimental converter converter.experimental_new_quantizer = False  # You can enable quantization if needed converter.experimental_enable_resource_variable = False  # You can enable resource variables if needed converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, gpu_delegate]

tflite_model = converter.convert()

Save the TFLite model to a file

with open('testing_gpu.tflite', 'wb') as f:     f.write(tflite_model)

Alwaysadil avatar Aug 30 '23 06:08 Alwaysadil

@Alwaysadil , Could you please try with the latest version of TensorFlow and Keras-NLP and let us know the outcome. Thanks

sachinprasadhs avatar Apr 23 '24 20:04 sachinprasadhs

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Feb 15 '25 01:02 github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] avatar Mar 01 '25 02:03 github-actions[bot]