Tensorflow:ImportError无法在retrain.py中导入名称graph_util

时间:2016-06-16 05:12:59

标签: python tensorflow

我从源代码编译Tensorflow以使用GPU。我能够成功安装它。它能够成功运行示例mnist convolutional.py脚本。

但是,当我在retrain.py中执行tensorflow/examples/image_retraining脚本时,它会发出以下错误:

Traceback (most recent call last):
  File "retrain.py", line 70, in <module>
    from tensorflow.python.client import graph_util
ImportError: cannot import name graph_util

使用命令和其他输出:

$ python retrain.py \
--bottleneck_dir=gpu_train/bottlenecks \
--model_dir=inception \
--output_graph=gpu_train/retrained_graph.pb \
--output_labels=gpu_train/retrained_labels.txt \
--image_dir categories
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.dylib locally
Traceback (most recent call last):
  File "retrain.py", line 70, in <module>
    from tensorflow.python.client import graph_util
ImportError: cannot import name graph_util

1 个答案:

答案 0 :(得分:5)

昨天有一个commit,它将文件graph_util.pytensorflow.python.client移到tensorflow.python.framework

您使用导入retrain.py的旧版from tensorflow.python.client import graph_util,但同时移动了graph_util.py,这很奇怪。

无论如何,graph_util.py的{​​{3}}是最新的(from tensorflow.python.framework import graph_util)所以你应该得到最新的版本(不需要再次编译,只需拉动)。