操作类型未注册 'BatchDatasetV2'

Op type not registered 'BatchDatasetV2'

我正在尝试训练模型并使用 tf.contrib.data.batch_and_drop_remainder 来准备我的数据集。当我 运行 estimator.train 我得到以下错误:

NotFoundError: Op type not registered 'BatchDatasetV2' in binary running on n-be8b2535-w-0. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resampler should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.

我没有尝试从已保存的图表中 运行,并且我已确保我使用的是新的 model_dir。我该如何解决?只有当我在 TPU 上 运行 时才会发生这种情况。 运行 在 CPU 上工作正常。

如果您的 VM 和 TPU 上有不同版本的 tensorflow,就会出现此错误。通过 运行ning:

检查 VM 上的版本
    import tensorflow
    print tensorflow.__version__

转到 GCP 控制台上的 TPU 页面,检查 TPU 上的版本: https://console.cloud.google.com/compute/tpus

通过pip 在您的VM 上设置tensorflow 的版本。所以如果你想将你的VM tensorflow版本设置为1.9,运行:

    pip install tensorflow==1.9