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/", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/[]/[]/[]/v1/[]/models/", line 124, in convert_lite
    lite_model = converter.convert()
  File "/home/[]/env/lib/python3.6/site-packages/tensorflow_core/lite/python/", line 446, in convert
  File "/home/[]/env/lib/python3.6/site-packages/tensorflow_core/lite/python/", line 449, in toco_convert_impl
  File "/home/[]/env/lib/python3.6/site-packages/tensorflow_core/lite/python/", 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 > <<EOF;
import tensorflow as tf

@tf.function(input_signature=[tf.TensorSpec(shape=[1], dtype=tf.float32)])
def simple(x):
  return tf.add(x,x)
converter = tf.lite.TFLiteConverter.from_concrete_functions([simple.get_concrete_function()])

The only guesses I have without more info is you are not sourcing the virtualenv script?


Related questions

Error occurred when finalizing GeneratorDataset iterator
ModuleNotFoundError: No module named 'tensorflow.contrib'
ModuleNotFoundError: No module named 'tensorflow.contrib' hot 4
When importing TensorFlow, error loading Hadoop hot 4
The flag 'log_dir' is defined twice. hot 3
[TF 2.0] Dataset has no attribute 'make_one_shot_iterator' hot 3
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 3
TF2.0 AutoGraph issue hot 3
Error loading tensorflow hot 3
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
No tf.lite.experimental.nn.bidirectional_dynamic_rnn ops is finded hot 3
Incorrect Error TypeError: padded_batch() missing 1 required positional argument: &#39;padded_shapes&#39; hot 3
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 2
Using tensorflow gpu 2.1 with Cuda 10.2 hot 2
Restoring Keras model fails inside a distribution strategy scope hot 2
Github User Rank List