为什么我不能在tensorflow中导入tfprof_log_pb2?

为什么我不能在tensorflow中导入tfprof_log_pb2?,tensorflow,anaconda,spyder,Tensorflow,Anaconda,Spyder,从中我了解到,新添加的概要文件工具是导入的,但它似乎很奇怪:1)它无法从交互界面导入;2) 在spyder中运行mnist示例时,我还收到一个错误,即:不能导入名称“tfprof\u log\u pb2” 我想既然tensorflow是在anaconda中安装的,那么它可能是一个旧版本,因此没有tfprof。但这只能解释为什么我不能直接在交互界面(不在anaconda环境中)中从tensorflow.tools.tfprof import tfprof_log_pb2运行,也不能解释为什么在an

从中我了解到,新添加的概要文件工具是导入的,但它似乎很奇怪:1)它无法从交互界面导入;2) 在spyder中运行mnist示例时,我还收到一个错误,即:不能导入名称“tfprof\u log\u pb2”


我想既然tensorflow是在anaconda中安装的,那么它可能是一个旧版本,因此没有tfprof。但这只能解释为什么我不能直接在交互界面(不在anaconda环境中)中从tensorflow.tools.tfprof import tfprof_log_pb2运行
,也不能解释为什么在anaconda中运行时会出现错误。它会在spyder中引发此错误,那么支持tfprof的版本应该存在

这两个答案都是正确的

在Ubuntu(python2.7和GPU)中,我走了一条捷径,通过以下方式将tensorflow从10更新为12:

pip安装\
-我https://pypi.tuna.tsinghua.edu.cn/simple/ \
https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp27-none-linux_x86_64.whl
在中国,我使用清华大学的镜子进行更快的安装。
直接进行得很顺利


但这似乎不适用于Mac(至少只适用于python3.5和cpu),即使您的tensorflow版本为12或更高,但该文件尚未生成(甚至其他两个文件也已在其中列出(
//anaconda/lib/python3.5/site packages/tensorflow/tools/tfprof/
),所以我只是复制了该文件(它必须与我的Ubuntu中的相同,对吗?)雅罗斯拉夫·布拉托夫私自进入文件夹。它可以工作。

磁盘上是否存在
tfprof_log_pb2.py
文件?它是自动生成的文件,不在源代码树中。相反,它被放在
bazel genfiles
目录中,应该在构建期间复制到发行版中

修复了其他工具丢失的一些文件,我想知道tfprof文件是否逃脱了修复(即,如果它不是
tools:all_files
target的一部分)


顺便说一句,从我的本地构建中复制该文件--

如果python的protobuf比3.1.0旧,而TF也旧,则会出现问题。我遇到的确切问题如下:

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL
$python

Python 2.7.10 (default, Jul 30 2016, 19:40:32)
>>> from tensorflow.tools.tfprof import tfprof_log_pb2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tfprof
之后,我安装了TF,如下所示:

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL
您会注意到TF 12.1安装了以下组件:

Collecting tensorflow==0.12.1 from https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl
Collecting numpy>=1.11.0 (from tensorflow==0.12.1)
Collecting protobuf>=3.1.0 (from tensorflow==0.12.1)
Collecting setuptools (from protobuf>=3.1.0->tensorflow==0.12.1)
成功安装TF后:

Successfully installed protobuf-3.1.0.post1 tensorflow-0.12.1
我尝试了第一个命令,如下所示:

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL
$python

Python 2.7.10 (default, Jul 30 2016, 19:40:32)
>>> from tensorflow.tools.tfprof import tfprof_log_pb2
>>> tfprof_log_pb2
<module 'tensorflow.tools.tfprof.tfprof_log_pb2' from '/Library/Python/2.7/site-packages/tensorflow/tools/tfprof/tfprof_log_pb2.pyc'>
Python 2.7.10(默认,2016年7月30日,19:40:32)
>>>从tensorflow.tools.tfprof导入tfprof_log_pb2
>>>tfprof_log_pb2

我知道它是由CPP程序生成的,因为存储库中的目录中的所有代码都是用C++编写的。