Ask questionstoco_from_protos: not found - breaking
Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18 LTS TensorFlow installed from (source or binary): binary TensorFlow version (use command below): v2.0.0-rc2-26-g64c3d38 2.0.0 Python version: 3.6
Command used to run the converter or code if you’re using the Python API
# Read the saved model from disk. Assumes it is downloaded. converter = tf.lite.TFLiteConverter.from_saved_model(model_out) lite_model = converter.convert() # Format model file paths to store the file in the right directory: lite_name = model_name + '.tflite' out_path = model_out + '/' + lite_name # Write the converted model to disk: open(out_path, "wb").write(lite_model)
Traceback (most recent call last): File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/home////v1//models/main.py", line 124, in convert_lite lite_model = converter.convert() File "/home//env/lib/python3.6/site-packages/tensorflow_core/lite/python/lite.py", line 446, in convert **converter_kwargs) File "/home//env/lib/python3.6/site-packages/tensorflow_core/lite/python/convert.py", line 449, in toco_convert_impl enable_mlir_converter=enable_mlir_converter) File "/home//env/lib/python3.6/site-packages/tensorflow_core/lite/python/convert.py", line 200, in toco_convert_protos raise ConverterError("See console for info.\n%s\n%s\n" % (stdout, stderr)) tensorflow.lite.python.convert.ConverterError: See console for info. /bin/sh: 1: toco_from_protos: not found
This happens, even after adding my python bin from the virtualenv to my $PATH variable.
It seems that the path to toco is hardcoded and therefore Tensorflow will never look for it anywhere else?
It's now not possible to use the converter in a Python virtualenv ( the recommended way to use Tensorflow )
Note that when activating the virtualenv from the commandline, the toco and toco_from_protos commands do work. It is only when running the Python program with Tensorflow that Tensorflow is not able to find toco_from_protos.
Answer questions aselle
I could not reproduce this. On linux you shouldn't have to manipulate your path and virtualenv should work. If you copy and paste this into a terminal that is exactly what I did. And it worked w/o any errors.
virtualenv -p python3 ~/py3-for-repro source ~/py3-for-repro/bin/activate pip install --upgrade tensorflow==2.0.0 cat > repro_test.py <<EOF; import tensorflow as tf @tf.function(input_signature=[tf.TensorSpec(shape=, dtype=tf.float32)]) def simple(x): return tf.add(x,x) converter = tf.lite.TFLiteConverter.from_concrete_functions([simple.get_concrete_function()]) converter.convert() EOF python repro_test.py
The only guesses I have without more info is you are not sourcing the virtualenv script?