为什么 google 深度学习 VM 上的 tensorflow 不使用 GPU?

Why doesn't tensorflow on google deep learning VM use GPU?

我正在使用来自 google 市场的 google 深度学习 VM,并且我选择了 NvdiaK80 GPU。我正在尝试使用对象检测 API 来训练对象检测模型。但是,我注意到 tensorflow 默认不使用 GPU(检查代码如下)

我的假设是此实例附带所有必需的 NVIDIA 驱动程序,因此它不是驱动程序相关的问题。

进一步调查显示我安装了 2 个 Tensorflow(tensorflow 1.12.0 和 tensorflow-GPU 1.12.0)。所以我卸载了 CPU 版本。然而还是没有用。

我使用下面的代码来检查 tensorflow 是否正在使用 GPU

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

作为参考,我使用下面的代码进行对象检测训练,它在深度学习 VM 上 运行 很好,但没有使用 GPU。

python $Tensor_path/legacy/train.py --logtostderr -- 
train_dir=$Train_path/training/ -- 
pipeline_config_path=$Train_path/training/
ssd_inception_v2_pets.config

输出(我期望正在使用的 GPU 设备细节)

[name: "/cpu:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 18292259467280600161
]

我能够通过删除旧实例并使用新实例重新开始来解决这个问题。我的猜测是在安装对象检测时 tensorflow GPU 安装损坏 API。按照此处的步骤安装 https://cloud.google.com/solutions/creating-object-detection-application-tensorflow

这行很可能是罪魁祸首

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