2025-08-06 10:59 PM - last edited on 2025-08-07 2:15 AM by Andrew Neil
Error output when trying to quantize CNN2d_ST_HandPosture_8classes_hand_posture_ST_VL53L8CX_handposture_dataset.h5 in STM Edge AI Developer Cloud. For example, the error "Could not find cuda drivers on your machine, GPU will not be used." Why do I need cuda drivers on my machine when I am running in the cloud? If anyone knows the cause of this error, please let us know.
Solved! Go to Solution.
2025-08-07 12:36 AM - edited 2025-08-07 12:37 AM
Hello @Shion,
The "Could not find cuda drivers on your machine, GPU will not be used." is just a warning, it is not the blocking point here. As you say, you don't need to install cuda on your pc.
The model is quite small even unquantized.
If you really need to quantize it, you can do it manually, for example:
import tensorflow as tf
# Load the Keras model from .h5 file
h5_model_path = 'CNN2D_ST_HandPosture_8classes.h5'
model = tf.keras.models.load_model(h5_model_path)
# Convert to TFLite model with post-training dynamic range quantization
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
# Convert the model
tflite_model = converter.convert()
# Save the quantized model to file
tflite_model_path = 'CNN2D_ST_HandPosture_8classes_quantized.tflite'
with open(tflite_model_path, 'wb') as f:
f.write(tflite_model)
print(f"Quantized model saved to {tflite_model_path}")
The model is smaller when quantized: 70kb -> 7kb. (h5 model -> tflitem model)
I let you verify this after convertion to C code.
In terms of inference time, it is the same:
Not quantized:
Quantized (with above script):
In term of accuracy, it needs to be tested, I think that if model zoo does not quantize it, it may indicate that you should not do it. But you can try (in the example script, it is quantized with random data. Quantizing it with real data is Highly recommended).
Have a good day.
Julian
2025-08-07 12:36 AM - edited 2025-08-07 12:37 AM
Hello @Shion,
The "Could not find cuda drivers on your machine, GPU will not be used." is just a warning, it is not the blocking point here. As you say, you don't need to install cuda on your pc.
The model is quite small even unquantized.
If you really need to quantize it, you can do it manually, for example:
import tensorflow as tf
# Load the Keras model from .h5 file
h5_model_path = 'CNN2D_ST_HandPosture_8classes.h5'
model = tf.keras.models.load_model(h5_model_path)
# Convert to TFLite model with post-training dynamic range quantization
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
# Convert the model
tflite_model = converter.convert()
# Save the quantized model to file
tflite_model_path = 'CNN2D_ST_HandPosture_8classes_quantized.tflite'
with open(tflite_model_path, 'wb') as f:
f.write(tflite_model)
print(f"Quantized model saved to {tflite_model_path}")
The model is smaller when quantized: 70kb -> 7kb. (h5 model -> tflitem model)
I let you verify this after convertion to C code.
In terms of inference time, it is the same:
Not quantized:
Quantized (with above script):
In term of accuracy, it needs to be tested, I think that if model zoo does not quantize it, it may indicate that you should not do it. But you can try (in the example script, it is quantized with random data. Quantizing it with real data is Highly recommended).
Have a good day.
Julian
2025-08-07 12:58 AM
Thank you for your comments! To be honest, I don't really understand ST Edge AI Developer Cloud, and I was just trying to confirm the flow by quantizing various models. I apologize for saying something inappropriate. Thank you very much for your detailed response.
2025-08-07 1:30 AM
No problem, feel free to ask anything.
Have a good day,
Julian