4

I am trying to compile the quantization script as described in Pete Warden's blog. However I get the following error message after running the following bazel build:

bazel build tensorflow/contrib/quantization/tools:quantize_graph
ERROR: no such package 'tensorflow/contrib/quantization/tools': BUILD       file not found on package path.
INFO: Elapsed time: 0.277s
Moe
  • 185
  • 1
  • 8

1 Answers1

8

I think what happened is that this quantization tool got moved out of contrib and into TensorFlow core. You should be able to use that instead:

bazel build tensorflow/tools/quantization:quantize_graph
Allen Lavoie
  • 5,778
  • 1
  • 17
  • 26
  • Thanks. That was it. – Moe Nov 04 '16 at 22:10
  • After I got this working the next command is : `bazel-bin/tensorflow/contrib/quantization/tools/quantize_graph \ --input=/tmp/classify_image_graph_def.pb \ --output_node_names="softmax" --output=/tmp/quantized_graph.pb \ --mode=eightbit` However I get this error: `Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter` from there. Got any idea on this? (I ran this in my tensorflow root directory) – Moe Nov 04 '16 at 22:11
  • I think it's the same cause. Try `bazel-bin/tensorflow/tools/quantization/quantize_graph \ --input=/tmp/classify_image_graph_def.pb \ --output_node_names="softmax" --output=/tmp/quantized_graph.pb \ --mode=eightbit` – Allen Lavoie Nov 04 '16 at 22:14
  • Well, that's what I am running (I just copied the example from Pete's blog here although I am running the bazel-bin/tensorflow/tools/quantization/quantize_graph) and it shows that it founds it and run it. The error that I am geting is related to some python code useed internally by quantize_graph here is the full output with error message: (next comment) – Moe Nov 04 '16 at 22:48
  • `Traceback (most recent call last): File "/home/moazzami/tensorflow/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/tools/quantization/quantize_graph.py", line 34, in import tensorflow as tf ...` `Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter from there.` – Moe Nov 04 '16 at 22:52
  • Hmm. I just cloned the TensorFlow repository again, ran `./configure`, `bazel build tensorflow/tools/quantization:quantize_graph`, and `bazel-bin/tensorflow/tools/quantization/quantize_graph --input=/tmp/classify_image_graph_def.pb --output_node_names="softmax" --output=/tmp/quantized_graph.pb --mode=eightbit`, and it runs with just a couple deprecation warnings and seems to work. Maybe try that? – Allen Lavoie Nov 04 '16 at 23:18
  • I think the issue that I have is that TF is somewhat confused between my Anocanda python and the python i have installed on my machine! - I guess .. – Moe Nov 04 '16 at 23:57
  • Yup, that was it, reconfiguring TF with right python address solved the issue. Thank you very much for your helps @Allen – Moe Nov 05 '16 at 00:13