Tensorflow 需要很长时间来恢复一个 ckpt 模型

Tensorflow takes a lot of time to restore a ckpt model

在tensorflow中恢复一个ckpt模型需要很多时间。我目前使用的是 tensorflow-gpu 1.0.0.rc0。我的模型大概500M左右,恢复模型大概需要1分钟。但是,当我使用 tensorflow-gpu 0.11.0 恢复相同模型时只需要几秒钟。知道为什么会这样吗?

很可能您的 1.0.0rc0 安装(为什么不正确更新到 1.0?)使用的是通过 pip 获得的纯 python protobuf 实现,而 0.11 安装使用的是改进的二进制分发版来自 google。

安装优化版本的 protobuf,详见 https://www.tensorflow.org/versions/master/get_started/os_setup#protobuf_library_related_issues 但是你可能想在 URL 中将 3.1.0 换成 3.2.0 以获得更新的版本(我遇到的问题是 3.2 "update" 通过 pip 并替换了优化的 3.1),所以而不是

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/protobuf-3.1.0-cp27-none-linux_x86_64.whl

使用

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/protobuf-3.2.0-cp27-none-linux_x86_64.whl

或类似内容,具体取决于您的平台和 python 版本。